There may be time when you will come across situation when you will need to change the HOSTNAME of your machine. It may be because you might have just cloned your virtual node for load-balancing or may be for any other reason but here is how you can change the HostName of your Ubuntu or Linux machine/node:
On first place how to find out Hostname of the Linux/Ubuntu Machine?
# just type in: (All caps are necessary) $ echo $HOSTNAME # output might be any name here let's say it is "myubuntu"
Now to change the Hostname of your Ubuntu (or most Linux) machine follow following steps:
# open hostname file for editing (either in VIM or your choice of editor be it edit, gedit or nano) $ sudo vim /etc/hostname # hostname file will get opened in vim (or vim or your choice of editor) # update new name and save the file and exit, that's it you're done. # Sometimes you may also want to edit name of file in hosts file to do that just type in another line at shell $ sudo vim /etc/hosts # you will see 2 entries in the file 127.0.0.1 localhost 127.0.0.1 myubuntu # Here change 2nd line which says myubuntu and update it to name of your desire and save and exit
That's it you don't need to do anything other than this to change HOSTNAME of your Ubuntu (or linux) system.