10.2 Host names
Checking and changing the hostname is done of 2 basic commands.
hostname to check the hostname and hostnamectl to control, change and check the hostname.
Checking the hostname
Display the current host name.
hostname
Result:
[root@rhcsa ~]# hostname
rhcsa.greateracademy.local
Or with hostnamectl.
hostnamectl status
Result will look similiar to this:
[root@rhcsa ~]# hostnamectl status
Static hostname: rhcsa.greateracademy.local
Icon name: computer-vm
Chassis: vm
Machine ID: 761eb1a7c2cc48198712a57c9f7cccc4
Boot ID: 677a772e4c7c4bc8a8b9953bc5444b05
Virtualization: kvm
Operating System: CentOS Linux 8 (Core)
CPE OS Name: cpe:/o:centos:centos:8
Kernel: Linux 4.18.0-80.el8.x86_64
Architecture: x86-64
This gives a lot of information as you can see. The most important information for us is the Static hostname: rhcsa.greateracademy.local this is the FQDN (Fully Qualified Domain Name) which means hostname rhcsa together with the domain name greateracademy.local.
Changing the hostname
Set a static hostname to match the current transient hostname.
Change the host name to rhcsa[xx].greateracademy.local Replace the X with your student number.
hostnamectl set-hostname rhcsa.greateracademy.local
View the configuration file providing the hostname at network start.
cat /etc/hostname
hostname
Display the hostname status at a config file:
[root@rhcsa ~]# hostname
rhcsa
Or with the hostnamectl command:
[root@rhcsa ~]# hostnamectl status
Static hostname: rhcsa.greateracademy.local
Icon name: computer-vm
Chassis: vm
Machine ID: 761eb1a7c2cc48198712a57c9f7cccc4
Boot ID: 677a772e4c7c4bc8a8b9953bc5444b05
Virtualization: kvm
Operating System: CentOS Linux 8 (Core)
CPE OS Name: cpe:/o:centos:centos:8
Kernel: Linux 4.18.0-80.el8.x86_64
Architecture: x86-64