How to Set / Change Host Name in CentOS 7 / RHEL 7 / Oracle Linux 7

See also: 

How to fix: unable to resolve host in Ubuntu


CentOS 7 supports three class of Host Names:

  • Static – The static host name is traditional host which can be chosen by the user and is stored in /etc/hostname file.
  • Transient – The transient host name is maintained by kernel and can be changed by DHCP and mDNS.
  • Pretty – It is a free form UTF -8 host name for the presentation to the user.
To temporarily set the host name of centos, use hostname command.

However, once the server is rebooted, the hostname will revert to it's previous setting.

hostnamectl can be used to change the host name and it can change all the three class of host name.

Check the current host name:

$ sudo hostnamectl status
$ sudo hostnamectl set-hostname i88ca
$ sudo hostnamectl status

Popular posts from this blog

How to get Active Transactions and Locks from MySQL

Example of a PAC file