In this post learn,how to change hostname in Ubuntu 12.04 and 12.10 without system restart.
Here, there are few steps through which we can change the hostname of system without reboot.

System OS: Ubuntu 12.04 LTS n l

Follow steps to change hostname in Ubuntu 12.04 LTS and Ubuntu 12.10

Step 1: Edit the /etc/hosts file and give the hostname which you want.
We have added the new line 127.0.1.1 tuxworld, this is our system new hostname.

root@mymachine:~$sudo vi /etc/hosts
127.0.0.1	localhost
127.0.1.1	tuxworld

# The following lines are desirable for IPv6 capable hosts
::1     ip6-localhost ip6-loopback
fe00::0 ip6-localnet
ff00::0 ip6-mcastprefix
ff02::1 ip6-allnodes
ff02::2 ip6-allrouters
191.168.122.26
root@mymachine:~$

Step 2: Now edit /etc/hostname and give the hostname you want. You can see here, we have given hostname as “tuxworld”.

root@mymachine:~$sudo  vi /etc/hostname
tuxworld
root@mymachine:~$

Step 3: Restart the /etc/init.d/hostname.sh (In Ubuntu 12.04)

/etc/init.d/hostname.sh restart

OR

Restart the /etc/init.d/hostname (In Ubuntu 12.10)

/etc/init.d/hostname restart

Step 4: Exit from the terminal and reopen once again.
You can also logout and login back to see the changes.

Step 5: Use hostname command to check hostname of system. This is how you can verify at the end.

Read Some More Articles

Leave a Reply

This site uses Akismet to reduce spam. Learn how your comment data is processed.