How to Change Hostname in Debian 10?


Debian is a widely used open-source operating system known for its stability and security. One of the essential aspects of a Linux system is its hostname, which is a unique name that identifies your computer on the network.

A hostname can be useful when you want to connect to your machine remotely or if you are running a server that other people need to access. Changing the hostname in Debian 10 can offer several benefits, such as better organization and identification of devices within your network.

Checking Current Hostname

Before we begin the process of changing the hostname in Debian 10, it is essential to check the current hostname. The hostname is a label assigned to a device connected to a network, identify and distinguish it from other devices in the same network. We will use a simple terminal command for checking the current hostname.

Terminal Command for Checking Current Hostname

$ hostnamectl status

The above command will run and provide us with information about our system's current hostname, including −

  • Static Hostname − This field displays your system's permanent name that is specified in the /etc/hostname file.

  • Icon Name − This field displays your system's icon name (Chassis type or model).

  • Pretty Hostname − this field shows a human-readable version of your system's static and transient hostnames if available.

  • Transient Hostname − the transient hostname is assigned dynamically by dhcp (dynamic host configuration protocol) or mdns (multicast domain name system).

  • Machines ID − this unique identifier represents your machine within systems management tooling.

A sample output after running `hostnamectl status` command may look like this −

$hostnamectl status 

Static hostname: debian-vm Icon name: computer-vm 
Chassis: vm Virtualization: oracle 
Operating System: Debian GNU/Linux 10 (buster) Kernel: Linux 4.19.0-14-amd64 
Architecture: x86_64

The above output shows that our system’s static host-name is “debian-vm”, and the icon name is “computer-vm”.

The system runs as a virtual machine, and the operating system is Debian GNU/Linux 10 (buster). Now that we have checked our current hostname, we can proceed to change it in the next section.

Changing Hostname via Command Line Interface (CLI)

While the graphical user interface (GUI) may be the preferred method for some users, changing the hostname in Debian 10 can also be accomplished using just the command line interface (CLI). This is a great option for users who prefer to work in the terminal or who do not have access to a GUI interface.

Terminal Command for Changing the Hostname

The terminal command for changing the hostname in Debian 10 is relatively simple. First, open up a terminal window and enter the following command −

sudo hostnamectl set-hostname [new-hostname] 

In this command, replace [new-hostname] with your desired hostname. It's important to note that you must use sudo before this command to ensure you have enough privileges to change the system's hostname.

Steps to Change the Hostname via CLI

The process of changing your system's hostname via CLI involves just a few simple steps −

  • Open up a terminal window.

  • Type "sudo nano /etc/hostname" and press Enter.

  • Edit your current hostname with your desired new name and save changes. Exit nano editor.

  • Type "sudo nano /etc/hosts" and press Enter.

Verification of Changes Made

To verify that you have successfully changed your system's hostname via CLI, enter the following command −


This will display your system's current hostname and other relevant information. Additionally, you can restart your system for changes to take effect across all services and applications. Overall, changing the hostname via CLI in Debian 10 is a straightforward process that allows users to easily customize their systems without requiring a GUI interface.

Changing Hostname via Graphical User Interface (GUI)

The Command Line Interface is not always the preferred method for all users, especially those unfamiliar with the terminal. Fortunately, Debian 10 has a user-friendly Graphical User Interface that makes it easy to change the hostname. The GUI method is similar to the CLI method but with a few additional steps.

Accessing the GUI Interface for Changing the Hostname

The first step in changing your hostname via GUI is to access your system settings. This can be done by clicking on “Activities” on the top-left corner of your screen and searching for “Settings” or simply pressing “Super key + I”. Once you have accessed Settings, click on “Details” and select “About” from the left navigation bar.

Steps to Change the Hostname via GUI

Once you have accessed About, locate “Device name” and click on it. A pop-up window will appear where you can enter your new desired hostname. Once you have entered your desired hostname, click on “Rename”. Your system will now apply your new hostname. Note: You may be prompted to enter your password before applying changes made through GUI.

Verification of Changes Made

To verify that changes were successfully made to your system’s hostname, open up terminal and type in −

hostnamectl status

This command will display detailed information about your system’s current settings including network interfaces, kernel version, and most importantly - hostname. Check if the displayed hostname matches with what you had set earlier through GUI.

Congratulations! You have now successfully changed your Debian 10’s Hostname using both Command Line Interface and Graphical User Interface!

Best Practices and Tips for Changing Hostname in Debian 10

Backup Your System Before Making Any Changes

Before making any changes to your system's hostname, it is crucial to back up your system. While changing the hostname may seem like a minor modification, it can have significant implications for your system, especially if you are using it for business or enterprise purposes. A backup will ensure that you can restore your system to its previous state if anything goes wrong during the change.

Choosing an Appropriate Name for Your System

When changing your system's hostname, it is important to choose an appropriate name that reflects the purpose of the system and adheres to established naming conventions. It is recommended that you avoid using special characters or spaces in the hostname as they can cause issues with certain applications and services. Additionally, make sure that the name you choose does not conflict with any existing hostnames on your network.

Testing Connectivity After Making Changes

After successfully changing your hostname, it is essential to test connectivity on your network to ensure that everything is functioning correctly. You should verify that all services and applications are working correctly without any issues.


Changing the hostname in Debian 10 is a simple but important task that can greatly benefit users. By changing the hostname, users can personalize their systems and make it easier to identify them on a network.

The article covered two methods of changing the hostname: via command line interface (CLI) and graphical user interface (GUI). It is also important to follow best practices when making changes to the system, such as backing up before making any modifications and testing connectivity after the changes are made.

Updated on: 24-Aug-2023


Kickstart Your Career

Get certified by completing the course

Get Started