How can I change the server's hostname?
The process of changing the hostname depends on the operating system used. For example, to change the hostname in CentOS 7, it is enough to run the following command in the console:
hostnamectl set-hostname new_hostname
instead of new_hostname, set the value you need.
To change the hostname in CentOS 6, open the /etc/sysconfig/network file and enter it in the HOSTNAME field, then run the command:
hostname new_hostname
instead of new_hostname, set the value you need.
In Debian and Ubuntu, you can change the hostname by opening the /etc/hostname file and entering a new value into it. You can do this by running the following command:
nano /etc/hostname
If the Nano text editor has not been installed on your server before, you can install it as follows:
sudo apt-get install nano
To change the hostname in FreeBSD, set a new value in the /etc/rc.conf and /etc/hosts files