Change Hostname on Centos 7


Temporary Change

sudo sysctl kernel.hostname=newHostname

Above change will be gone once server is restarted. To permanently change the hostname follow the steps below:

Permanent Change

→ sudo su [If not already a sudoer]
→ nmtui 
   [This will prompt the gui, select the hostname and change to newHostname]
→ restart the server


Done!