How to Change Hostname on Ubuntu 11.10

This post will shows you how to quickly change hostname on Ubuntu 11.10. Assumed that you have root account access on Ubuntu 11.10 linux server. There are two way to change the hostname on Ubuntu serve or desktop. Either you modify /etc/hostname using vi command or simply run the echo command as shown on example below :

1. Modify /etc/hostname using echo command :

root@ubuntu11:~# echo > /etc/hostname

2. Modify /etc/hostname using vi editor and enter your new hostname :

root@ubuntu11:~# vi /etc/hostname

This steps is required for both above steps (1) and (2). To get the new hostname to take effect, restart the hostname as below :

root@ubuntu11:~# /etc/init.d/hostname restart
Rather than invoking init scripts through /etc/init.d, use the service(8)
utility, e.g. service hostname restart

Since the script you are attempting to invoke has been converted to an
Upstart job, you may also use the stop(8) and then start(8) utilities,
e.g. stop hostname ; start hostname. The restart(8) utility is also available.
hostname stop/waiting

How to check the updated or current hostname :

root@ehowstuff:~# hostname