How to Set or Change Hostname in Linux System

As when I was new to Linux OS, I setup my computer name or hostname to “sachin-P5WE0” during installation but now I want to change it to Don’t Dare to Open“. So, I figured it out and made others also available with the commands in this post. Read it to give your choice name or a caption to your PC.


A hostname could be a label which is assigned to a device or tool connected to a network which is employed to spot the device in varied types of transmission, such as the World Wide Web. Hostnames could be simple names consisting of a one word or phrase, or they’ll be structured.

Follow the steps to set or change your Linux system hostname:

1. Display your current system hostname

$ hostname



2. Edit /etc/hostname using text editor

Type the following command to edit /etc/hostname using any text editor you are comfortable on( I’m using nano text editor)

sudo nano /etc/hostname





The above command shows you the old system’s name, edit it with the new name. Save it and check by the display command again.

3. Also edit the /etc/hosts file

Enter the following command to replace the old name if occurs anywhere with the new name of your choice.

sudo nano /etc/hosts





This will finally replace the old name of your Linux system with the new name but to make changes in effect, you have to execute the final step.

4. Reboot the system

In order to make changes in effect, you have to reboot your system either manually or you can use the following command;

sudo reboot

Hence, you have got the new name for your system so that if anyone switches your system ON he/she can see the name or any caption given by the admin.

You can give some suggestions by posting comments or Contacting us and tell us if you have any problem. We will try solving it and help the people in doubt. If anyone wants to make any donations they can also contact us for the welfare of the website. Soon, there will also be a post regarding server hostnames and many server related solutions.

5 Comments on How to Set or Change Hostname in Linux System

Leave a Reply

Your email address will not be published.