This howto will show you how to set the RHEL7 hostname (Redhat 7 or CentOS 7) based machine. If you have built your new RHEL7 based machine and have now got a bit stuck over how to change the hostname from localhost.localdomain to what ever you want this is the how to for you.
There are three typs of hostnames: Static, Pretty and Transient.
The Static hostname is essentially the traditional hostname which can is stored in the “/etc/hostname” file. This is the hostname that can be set by the system admin.
Change this file and reboot and your hostname should be permanently changed. Note that the hostname can be changed by editing the “/etc/hostname” file or with the hostnamectl command.
[root@localhost ~]# hostnamectl set-hostname server.domain.tld
Also note that this command will set all three hostnames at the same time, but all three can be set indivdually using the “-static”, “-transient” or “-pretty” flags.
Validate “/etc/hostname” has been updated
[root@localhost ~]# cat /etc/hostname server.domain.tld
[root@server ~]# hostname server.domain.tld
The Transient hostname is a dynamic hostname which is maintained at a kernel level. It is initialized by the static hostname, but can be changed by DHCP and other network services.
The Pretty hostname is a free form hostname for presentation to the user.
You can see a bit of information with the hostnamectl command which is very useful. man hostnamectl
[root@server ~]# hostnamectl Static hostname: server.domain.tld Icon name: computer-vm Chassis: vm Machine ID: xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx Boot ID: xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx Virtualization: vmware Operating System: CentOS Linux 7 (Core) CPE OS Name: cpe:/o:centos:centos:7 Kernel: Linux 3.10.0-123.4.4.el7.x86_64 Architecture: x86_64