Change hostname on a Red Hat or CentOS server
Change the hostname on a Red Hat Enterprise Linux (RHEL) or CentOS server using the hostnamectl command and replacing <newhostname>. Then reboot using shutdown -r or init 6. You will need root or sudo permissions to make this change.
#hostnamectl set-hostname <newhostname>
#shutdown - r
After mmaking the change you can check it’s been applied using the hostnamectl command without any options.
#hostnamectl