Q: How to change hostname on Ubuntu 16.04?

Hostname Ubuntu Linux


On Linux, hostname file is located in /etc/hostname. We can change the hostname by editing this file. To edit the hostname using vim, run the following command:

sudo vim /etc/hostname 

(Optional) You can edit the /etc/hosts and add your hostname.

sudo vim /etc/hosts
Add the following line to your hosts file. Rename text in red with your hostname.    hostname 
Now we have to restart the server for the server to use the new hostname:
sudo reboot
    No comments found for this tutorial, be the first to leave a comment!

Answered by

Last updated on
Aug 05, 2016