I’ve been asked this question a million times and there has been no real straight answer.. So I’ve decided to make a post on this for the benefit of everyone.
Frankly I am surprised that an OS that can do so many thing ,’so dam well’ with simple cmds is unable to change hostname cleanly.
Anyway this will do the trick for you..
Edit the following files and add the new name you want to in place of the existing ones.
Edit these 3 files and reboot to permanently change your hostname.
Some other methods include
(however this changes the hostname only for 1 logged in session.Although useful at times it will be a pain in the long run if you fail to remember that the change has to be done every time.)
(I’ve read and used this cmd to try and change.. but this cmd unconfigures the running machine entirely and a complete overhaul is required.. something that I would not recommend.)
Choose the first option and your good to go.