When you are done installing a machine, setting up a user-friendly and meaningful hostname is one of the task system administrators need to do.

In this article, I am going to show you how to change the hostname on Debian 10 machine.

How to Display the Current Hostname?

If you want to find out the current hostname, execute the following command on the terminal.


This will show you the short version of the hostname. To get the full or FQDN (fully qualified domain name) version of the hostname, use this command:

hostname -f

As shown in the following screenshot, the short hostname on my system is just “debian”.

How to Change the Hostname?

Open the terminal and login with root. Execute the following command to open the hostname file for changes.

nano /etc/hostname

Edit hostname in nano editor

Replace the old name with a new hostname. A few general notes to choosing a hostname:

  1. The hostname should be unique in your network. So don’t use the hostname twice.
  2. The hostname should be lowercase.
  3. It is recommended to use just alphanumeric characters (a-z, 0-9) and the “-” (minus char)

Suppose server1, save the changes and exit the editor.

Reboot the system so that changes can take effect. The following screenshot shows that the hostname has been changed.

Debian Hostname

How to Change the Host Name Without Restarting the Debian 10 Machine?

Open the terminal with root privileges and execute the following command. Replace name-here with the name of your server.

hostname <name-here>

Next, edit the hostname file and update the hostname.

nano /etc/hostname

Save and close the file.

The hosts file in Debian

Finally, open the hosts’ file and replace the old name with the new name.  The lines should be read as follows. your-old-host-name

Save and close the file.

How to Change the Hostname in Debian 10

Karim Buzdar

About the Author: Karim Buzdar holds a degree in telecommunication engineering and holds several sysadmin certifications. As an IT engineer and technical author, he writes for various web sites. You can reach Karim on LinkedIn