Ubuntu Changing Hostname

Need to change your hostname? Use the following command.

1
# sudo hostname <new-hostname>

Now edit /etc/hosts and change the line starting with “127.0.1.1”.

1
2
3
# sudo nano /etc/hosts
 
127.0.1.1     old-hostname <- replace this line to your new-hostname

Now reboot your server, for new host name to take effect.

1
# sudo reboot