Wednesday, March 20, 2013

Fix machine hostname return null as it value

If your getting null value as your host name, check that both /etc/hosts and /etc/hostname files has the same name to the host, If not put the same name to both file as hostname, Here[1] you can find how to do that.

How to change machine name in Ubuntu 12.04 LTS

Go to the terminal
Type "sudo su" , because you need log into root mode to modify following files.
Now type "gedit /etc/hostname"
Replace new name with old name
Save and close the file

Now type "gedit /etc/hosts"
Replace your new name with old name
    eg : 127.0.1.1 <old name>    -->   127.0.1.1 <new name>
Save and close the file

Now you need to restart the machine, type "reboot" in terminal to restart via terminal.
Now you have successfully changed machine name. 

Sample Text

Website counter

Categories