How to change hostname on Debian 10 Linux

There is no greater hope in human life than survival. At the same time, it is important to live well. With that in mind, every content on the website is written so that a person can get all the information from here to start his life to make beautifully.

According to that, Technology is one of the topics. It is also a part of life. Read carefully Details of Technology related article

How to change hostname on Debian 10 Linux

How do I change the hostname of a Debian Linux 10 “Buster” operating system permanently using the command line tools?

You can use the hostnamectl command or hostname command to display or set the Debian Linux system’s host name. In this tutorial, you will learn how to change your hostname on Debian Linux.

Tutorial details
Difficulty level Easy
Root privileges Yes
Requirements Debian Linux
Est. reading time 3 minutes

Change hostname on Debian 10 Linux

  1. Login to your server: ssh user@server-name
  2. Become a root user using either sudo -s or su -
  3. To set the hostname to server1, run: hostnamectl set-hostname server1
  4. Edit the file /etc/hosts and update entries: vi /etc/hosts
  5. Verify it by running the hostnamectl command again.

Let us see all commands in details.

Display the current hostname for Debian Linux

Simply run the following command:

The current hostname is set to localhost

Change the hostname on Debian 10

Now you know how to view the current hostname. It is time to change it as per your needs. A hostname is nothing but a name that identifies your Debian box on a network. Typically for the server, you set it as FQDN (fully qualified domain name) such as The syntax is as follows:
hostnamectl set-hostname {name-here}
For example, to change the system hostname to in Debian 10, you can use the following command:
sudo hostnamectl set-hostname
Next, edit the /etc/hosts file, run:
vi /etc/hosts
Find all references to oldname and replace with newname except for the following entries:


Patreon supporters only guides 🤓

    • No ads and tracking



    • Join my Patreon to support independent content creators and start reading latest guides:


Join Patreon	localhost

# The following lines are desirable for IPv6 capable hosts
::1     localhost ip6-localhost ip6-loopback
ff02::1 ip6-allnodes
ff02::2 ip6-allrouters

For example:	localhost

# The following lines are desirable for IPv6 capable hosts
::1     localhost ip6-localhost ip6-loopback
ff02::1 ip6-allnodes
ff02::2 ip6-allrouters

Save and close the file.

Verify the change

How do you know that hostname was successfully changed? You use the same command without any arguments. In other words, type the following command:

Set a particular pretty host name

The syntax is:
hostnamectl set-hostname "Vivek's Thinkpad" --pretty

Changing Debian host names remotely using ssh

From your Linux desktop, run:
hostnamectl set-hostname -H [username]@hostname
hostnamectl set-hostname {new_name_here} -H root@
hostnamectl set-hostname -H root@

The hostnamectl tool will use SSH to connect to the remote system. One can see help page by typing:
hostnamectl --help
Sample help page:

hostnamectl [OPTIONS...] COMMAND ...
Query or change system hostname.
  -h --help              Show this help
     --version           Show package version
     --no-ask-password   Do not prompt for password
  -H --host=[USER@]HOST  Operate on remote host
  -M --machine=CONTAINER Operate on local container
     --transient         Only set transient hostname
     --static            Only set static hostname
     --pretty            Only set pretty hostname
  status                 Show current hostname settings
  set-hostname NAME      Set system hostname
  set-icon-name NAME     Set icon name for host
  set-chassis NAME       Set chassis type for host
  set-deployment NAME    Set deployment environment for host
  set-location NAME      Set location for host
See the hostnamectl(1) man page for details.


On Debian Linux hostnamectl command used to query and change the system hostname and related settings. For more information see the man page here or read it locally using the man command:
man hostnamectl




Did you like this article?
Share it on any of the following social media channels below to give us your vote. Your feedback helps us improve.

Other related Technologies ideas you might enjoy

Related Articles

Leave a Reply

Your email address will not be published.