How to Change Host Name in Linux

In this tutorial, we will show you how to change host name in linux.


Hostname is a tag or name denoted to any device connected with the computer. Follow this step by step guide to learn how to change host name in linux. With the help of this tutorial, you will be able to change your hostname on your Linux machine.

Step 1 – Hostname Editor Window

First of all, open up the terminal application. In this tutorial, you will see that currently our hostname is Ubuntu. To change hostname, type in

“sudo gedit /etc/hostname” and hit the enter key to proceed further. This will open up the hostname editor window.

Open Hostname Editor

Step 2 – Change hostname

With the editor opened up, let’s change the host name. From ubuntu, change hostname to “Test-Server” for the purpose of this tutorial. Save the changes made once you are done.

Edit hostname

Step 3 – Restart System

You will need to restart the system. A restart is necessary for the changes you just made to take effect.

Restarting the system for the changes to take effect

Step 4 – Hostname has been changed

Once the system has been restarted, you can see in the terminal application that the host name has been changed. In this tutorial, we had changed the hostname to Test Server. You will notice that after the reboot, the hostname has changed as per our specifications.

Modified hostname