Greenwebpage Community Blog Tutorials How to Change Hostname on Debian 12
Tutorials

How to Change Hostname on Debian 12

Hostname is a unique name of your system that helps other devices to recognize your system. It is used to communicate with other systems. Like other operating systems, the Debian 12 also allows you to personalize your system.

For example, using simple and easy-to-use steps you can change the hostname as per your preference.

In this article, you will learn how to change or personalize your system hostname on the Debian 12 system.

How to Change Hostname on Debian 12?

This article will cover the following two methods to modify or update the hostname on Debian 12 system:

  • Method 1: Change Hostname using “set-hostname”
  • Method 2: Change Hostname Through “/etc/hostname”

Method 1: Change Hostname using “set-hostname”

This method covers how to use the “set-hostname” command to change your Debian’s hostname.

Step 1: View Current Hostname

The “hostname” is a simple command that displays the current hostname of your Debian 12 system:

hostname

hostname

Here, you can view the hostname currently set on your Debian system, such as “Debian12”.

Step 2: Change Hostname via “set-hostname”

Next, run the command in the following manner to set a new hostname like “DebianXII”:

sudo hostnamectl set-hostname DebianXII

Step 3: Apply Changes without Rebooting

To take effect the changes you made, you need to reboot your Debian system. However, the following command will update your system without rebooting it:

newgrp

You can see the changes in your terminal; Debian12 to DebianXII.

Method 2: Change Hostname Through “/etc/hostname”

You can also modify the hostname of your system using “/etc/hostname”.

Step 1: Access “/etc/hostname”

Utilize the text editor (i.e. Nano) to access the hostname file from the Debian terminal:

sudo nano /etc/hostname

Enter your password to access the sudoers file.

Step 2: Change Hostname

In the hostname file, update or change the hostname of your choice. For example, we have changed the hostname from “Debian12” to “DebianXII”:

DebianXII

Step 3: Reboot Your System

Without rebooting your system, the changes made in the hostname file may not take effect. Thus, restart your system using the command:

sudo reboot

Step 4: Verify the Updated Hostname

From the terminal, use the hostnamectl command to verify whether the hostname has been updated or not:

hostnamectl

The above details show that the Static hostname has been changed to yours, “DebianXII”.

With the above two methods, you have successfully changed the hostname of your choice on the Debian 12 system.

Conclusion

On Debian 12, you can change or modify the hostname according to your preferred hostname. You can use the command “sudo hostnamectl set-hostname DebianXII” or “sudo nano /etc/hostname” to change the current hostname to the new one.

This post explained in detail how to change the hostname on Debian 12.

Exit mobile version