Ubuntu Changing Hostname

Need to change your hostname? Use the following command.

# sudo hostname <new-hostname>

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

# 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.

# sudo reboot