HostOnNet Blog

Change Hostname In Debian or Ubuntu

Looking for Linux Server Admin or WordPress Expert? We can help.

You can change hostname by editing file /etc/hostname

root@fwhwin:~# vi /etc/hostname

Then you will get an output like:

hostname

Replace the current host name with the desired new name.

Save and close the file.

Then You need to edit the /etc/hosts file, enter:

# vi /etc/hosts

Change all old hostname with newer one:

127.0.0.1       localhost
127.0.1.1       fwhwin

# 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

Save and close the file. Then reboot the system.

About Annie

I've been working in Technical Section for over 10 years in a wide range of tech jobs from Tech Support to Software Testing. I started writing blog for my future reference and useful for all.
Posted in Linux

Leave a Reply

Your email address will not be published. Required fields are marked *

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