You can use the shell command hostnamectl. in Centos OS to see current configuration information.
We want to replace the old hostname with a new name. To do this, we use hostnamectl set-hostname <hostname>.
That’s it. The hostnamectl command is a simple way to change the hostname under CentOS 7.
The machine used for this example was a VM setup for this example, but this works the same way in a non vm machine.