Change Hostname in Ubuntu

by Administrator 14. May 2009 03:43

I had this problem where the hostname I had chosen was the same on another Windows machine on the network. Therefore, I was unable to browse the network in Gutsy Gibbon. I wanted to change the hostname so I tried the following:

sudo hostname mybrandnewname

But it would not change. It would say the name had changed but after a reboot the old name would be restored. So people at Ubuntu Forums helped someone in the same predicament. The user was unable to change hostname. I followed their instructions and here they are 

sudo vim /etc/hosts

Change the old hostname to the new one. For example, my /etc/hosts file said

192.168.168.100 oldhostname

So I changed it to

192.168.168.100 newhostname

I also edited the /etc/hostname file.

sudo vim /etc/hostname

It read

oldhostname

So I changed it to

newhostname

After doing the following, the new hostname stuck as required.

sudo /etc/init.d/network restart

You should really read hostname error not resolving for more details.

As for my original problem of not being able to browse the network, it was solved with this fix.

Tags:

Add comment

  Country flag

biuquote
  • Comment
  • Preview
Loading

 

My Quote :P

Each morning when I open my eyes I say to myself: I, not events, have the power to make me happy or unhappy today. I can choose which it shall be. Yesterday is dead, tomorrow hasn’t arrived yet. I have just one day, today, and I’m going to be happy in it.

Month List

Page List