How to Change the Hostname in Debian 12 BookWorm

In Debian 12 and even in other operating systems hostname plays a quite important role. It helps the machine to get identified on a network. However, when we install OS, it sets the hostname automatically which sometimes needs to be personalized. In that case, to change the current hostname to the one we want, a user can either use the Graphical user interface or the command line terminal.

Here in this article, we learn various ways to update the hostname in Debian 12 Linux server or desktop.

1: Access the Terminal

If you are using a Graphical user interface then to change the Hostname using the terminal, we have to open it first. Go to Application and search “Terminal” as its icon appears, and click to open it.

2. To check the current hostname

As our system already has a pre-assigned hostname to check what it is, we have a command to run in a terminal, here is that.



check the current hostname

#1st method:

3. Setting up Debian 12 Hostname – temporary

Well, if you don’t want your Debian 12 hostname to change permanently instead of just for the current session then that is possible as well. For that, in your command terminal type the given command:

sudo hostname new-one

Replace the new-one with the hostname you want to assign to your system temporarily. To see the changes, initialize your current environment or refresh your current session using:

Setting up Debian 12 Hostname temporary

#2nd Method:

4. Use hostnamectl set-hostname

Well, if you want to change your hostname permanently without rebooting your Debian 12 Linux, then use the “hostnamectl set-hostname” command.

sudo hostnamectl set-hostname new-one

To see the changes on your terminal, refresh the session:

Use hostnamectl set hostname to change

#3rd Method:

5. Edit /etc/hostname and /etc/hosts

Another method to change the name of your computer is by editing two files – /etc/hostname and /etc/hosts. However, after editing these configuration files the user has to restart the system to apply them. This method is also permanent.

sudo nano /etc/hostname

You will see your existing hostname in the file, just change it to whatever you want to set. To save the file press Ctrl+O, hit the Enter key, and then to exit use Ctrl+X.

Change debian 12 hostname using etc file

In the same way, also edit the host file and change your existing hostname in that as well. This file is used to map the hostnames to the IP address. This configuration is important when the user wants to resolve some IP address with the hostname.

sudo nano /etc/hosts
resolve some IP address using hostname

After editing and saving the files reboot your system.

sudo reboot

6. Use GUI to Change the Debian 12 Hostname

Well, those who are not comfortable with the command-line method and using a graphical desktop can go for the GUI method.

  • Go to the Debian 12 GUI Setting app.
  • Select the About section given in the left side menu.
  • Click on the Device Name
  • Enter the new hostname you want to use.
  • Click on Rename button to Save the changes

Enter your password when prompted.

Once the system restarts, the new hostname will be in effect.

Debian 12 GUI Setting
About section
Rename Device name in Debian 12


Changing the hostname in Debian 12 is quite simple like Ubuntu and other Linux systems. You can use either Terminal or GUI whichever is suitable for you to customize and update the hostname. However, remember to choose a valid hostname, which means there must not be a space between the hostname you are setting up for your Debian 12 system.

Other Articles:

1 thought on “How to Change the Hostname in Debian 12 BookWorm”

Leave a Comment

This site uses Akismet to reduce spam. Learn how your comment data is processed.