In the CentOS 7 system(minimal installation), there are three types of hostname as static, transient and pretty.
What is the different type?
The “static” hostname is stored in “/etc/hostname” file and is used to initialize the kernel hostname at boot.
The “transient” hostname is a temporary hostname which specified by DHCP or DNS server.
Both static and transient hostnames follow the same character restriction rules as Internet domain names.
As to the “pretty” hostname, it is stored in “/etc/machine-info” file and allow user to set all kinds of special characters(ex: “DAVIDWA DESKTOP”).
How to change it?
Change all types hostname
If we want to change the three types of hostname at the same time, we can do it by using the sudo hostnamectl set-hostname <new hostname> command.
Change the special type hostname
If you want to change a particular hostname only (static, transient or pretty), you can use "--static", "--transient" or "--pretty" option. For example, to change hostname permanently, you can change the static hostname by using the sudo hostnamectl --static set-hostname <new hostname> command
After change the hostname, It may be necessary to restart the systemd-hostnamed daemon so that as to reflect the change in Static hostname by using the sudo systemctl restart systemd-hostnamed command
Check the current hostname
If we want to view the hostname of the CentOS 7 system, you can use “hostnamectl” or “hostnamectl status” command directly.
or use hostnamectl status [--static|--transient|--pretty] to view static, transient or pretty hostname, respectively.
After reboot it and log in again, the system will display the new hostname now.