Change the Hostname of a CentOS Server

For changing the Hostname of a CentOS Server follow steps below:

  1. Open the global network configuration file:
    nano /etc/sysconfig/network
  2. Find the HOSTNAME setting. It’s default value will looks like below:
    HOSTNAME=localhost
  3. Replace that localhost value with chosen fully qualified domain name.
    HOSTNAME=centos.tekbloq.com
  4. Save changes and exit and reboot the server for applying host name changes immediately