Change hostname on Ubuntu 12

How to change hostname on Ubuntu 12

This guide will help you to change hostname on Ubuntu 12.

Present hostname on Ubuntu

root@ubuntu:~# cat /etc/hostname
ubuntu

So we need change that file for new hostname

root@ubuntu:~# vi /etc/hostname
Ubuntu12Server
root@ubuntu:~# cat /etc/hostname
Ubuntu12Server
root@ubuntu:~#

Also we need change /etc/hosts to recognize the new hostname

Present /etc/hosts

root@ubuntu:~# cat /etc/hosts
127.0.0.1 localhost
127.0.1.1 ubuntu
# 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
root@ubuntu:~#

We need change to

vi /etc/hosts
127.0.0.1 localhost
127.0.1.1 Ubuntu12Server
# 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

You can reboot the server to take affect with new hostname Or you can use this command to apply the change without reboot

/etc/init.d/hostname.sh start

Now we get the new hostname in Ubuntu.

login as: root
root@192.168.0.113’s password:
Welcome to Ubuntu 12.04.1 LTS (GNU/Linux 3.2.0-29-generic-pae i686)* Documentation: https://help.ubuntu.com/
Last login: Wed Dec 5 00:56:35 2012 from 192.168.0.105
root@Ubuntu12Server:~#
root@Ubuntu12Server:~#

That’s all. Thanks for using IThelpblog.com