How to change hostname in Debian 10

The computer name or host name of the system is used to identify it on the network. You are asked to provide a computer name or host name when installing the OS, and it must be unique in order to avoid conflicts. Later, when you want to change the name of your computer, you will need to execute several commands or make changes to some configuration files.

In this article, we will talk about some ways to change the name of your computer through the graphical user interface and command line.

We launched the commands and procedures mentioned in this article on Debian 10.

Changing hostname in Debian 10

Method 1: Through the GUI

To change the host name through the GUI, click the down arrow in the upper right corner of the Debian desktop. From the drop-down menu, click on the “Settings” icon as shown below to launch settings utility.

Alternatively, you can open settings utility from the Dash system menu. Press the super-key on the keyboard, then in the search bar enter Settings When the utility appears, click on it to open.

Open Settings

Now go to the details Tab from the left pane. You will see the device name or host name in About see as below:

About your computer

This way your hostname will be changed. However, remember that changing the host name using this method is not permanent. It will revert to the old name when you reboot the system.

Method 2: through the host name and hosts file

The computer name or host name can also be changed using host name team. To view the current host name, simply enter host name In the Terminal:

$ hostname

Hostname command

Now, to change the computer name, use the following command syntax:

$ sudo hostname new_hostname

replace new_hostname with the one you want to install for your system.

Set a new hostname using the hostname command in Debian 10

This is also a temporary way to change the computer name. There is also a way to permanently change the computer name. To do this, we will need to edit two different configuration files with the name / Etc. / hostname and / etc. / hosts file.

Edit first File / etc / hostname by entering the following command in Terminal:

$ sudo nano /etc/hostname

Edit the file / etc / hostname

It will indicate the name of your computer. Change the computer name to a new one, and then click Ctrl + O and Ctrl + X save and exit the file at the same time.

Then edit / etc. / hosts file as follows:

$ sudo nano /etc/hosts

You will see the computer name in the list against IP: 127.0.1.1

Edit the file / etc / hosts

Change the name of this computer to a new one, and then save and exit the file using Ctrl + O and Ctrl + X at the same time. Now the computer name that you just installed will remain unchanged even after rebooting the system.

Method 3: using the hostnamectl command

There is another team hostnamectl using which you can change the name of your computer.

Now just type hostnamectl in your terminal. It will display detailed information about your system, including the computer name or host name.

$ hostnamectl

Retrieve computer device name information using the hostnamectl command

To change the hostname of a computer through hostnamectl use the following syntax:

$ hostnamectl set-hostname "new_hostname"

replace new_hostname with the one you want to install for your system.

Set a new hostname using hostnamectl

Run the systemctl command again, now you will see the new host name that you set using the hostnamectl command.

Conclusion

In this article, we learned how we can change the computer name in the Debian OS. Changing the computer name using the GUI or hostname command is a temporary method, and editing the configuration files / etc / hostname and / etc / hosts provides a permanent way to change the computer name.

How to change hostname in Debian 10

Sidebar