- Edit the “/etc/hostname” file, change the current hostname to the desired hostname.
vim /etc/hostname
- Edit the “/etc/hosts” file, replace the old hostname with the new one.
vim /etc/hosts
- Then run the following command:
/etc/init.d/hostname.sh start
That’s it!
To view the current hostname, use the “hostname” command.