Change Hostname Linux

Hi all, if you want to change the hostname of your server/under linux operating system, you can follow the steps pasted below.

There are networking programs such as sendmal, apache servers etc use hostname to identify the machine.

The hostname command can be used to change or modify the hostname of a machine, it is for displaying or setting up the current domain or hostname of the system.

Display Hostname : 

You can simply enter ‘hostname’ in the command line to get to know the current hostname of the system.


Change Hostname : 

The following methods can be used to change the hostname depending on your linux distribution.

For operating systems :

Redhat / CentOS / Fedora:

Edit the file, /etc/sysconfig/network :

vi /etc/sysconfig/network

Set hostname to the name that you need to set.

Now save and exit vi editor.

For operating systems :

Debian / Ubuntu:

Edit the /etc/hostname file using your favorite text editor.

vi /etc/hostname

Now, delete the old name and set new name.

Save and quit the text editor.

That’s it 🙂

Leave a Reply

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