How to Set or Change Hostname in Linux System

Home/Linux/How to Set or Change Hostname in Linux System

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.

Hostname

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

 

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

 

etc_hostname

old_name

new_name

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

 

etc_hosts

hosts_oldname

hosts_newname

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.

By | 2017-05-22T19:11:34+00:00 May 3rd, 2017|Linux|5 Comments

About the Author:

5 Comments

  1. Melissa Jellie May 4, 2017 at 3:35 pm - Reply

    Interesting information!

  2. theconfusedsoulsree May 4, 2017 at 3:37 pm - Reply

    Great informative post and tutorial :)

  3. Christie Moeller May 4, 2017 at 5:02 pm - Reply

    Great step by step- super helpful!

    xoxo Christie

  4. Eryn May 4, 2017 at 10:40 pm - Reply

    Thank you for the detailed instructions! It’s greatly appreciated!

  5. Mishelle Milne May 5, 2017 at 3:41 pm - Reply

    Very useful thank you.

Leave A Comment

seventeen + 12 =

Avada WordPress Theme