How to change the Hostname in Ubuntu

There are times you may come up with a need for change in your computer’s identity over network. This is when you will have to change the Hostname of your computer. The hostname is pretty much like a label to your computer or the device for identification over the network. The hostname can be just a simple name, an IP Address or even a domain name.

To change the hostname in Ubuntu, follow these simple steps:

1. Find out your existing hostname by entering this command in terminal:


hostname ubuntu

So on my computer, the hostname is “santhosh-desktop”

2. Change the hostname by editing:

sudo nano /etc/hostname

You will see the existing hostname. Change it to whatever new hostname you want and save it by hitting Ctrl + O

In this tutorial, I change it to


3. Now edit the hosts:

sudo nano /etc/hosts

Here change the ::1 and to the new hostname you chose.

::1 gigacore-desktop localhost6.localdomain6 localhost6 gigacore-desktop

3. Restart the hostname service.

sudo /etc/init.d/hostname restart

Now check the hostname by following the step 1 and you should see the new hostname.

Tags: , , , , , , ,
Copyright 2017. All rights reserved.

Posted March 31, 2011 by Santhosh in category "Linux