Changing the host name of your CentOS machine

When I create a new virtual private server (VPS), upon logging in for the first time, I'm presented with something like:

[root@vps4554687 ~]

This is fine, but I usually want to change the host name that gets assigned to the instance to something more identifiable than vps4554687.

This can be done with a single command:

hostnamectl set-hostname [YOUR_HOST_NAME]

If you are not logged in as root, it will ask for your sudo password. When logging back in, the command terminal will show [root@your_host_name ~].

(Naturally, another step would be disabling root login, but that's something else.)

Source: https://www.cyberciti.biz/faq/rhel-redhat-centos-7-change-hostname-command/