How to Change Hostname on Debian 12, 11 or 10

Changing a device’s hostname in network configurations is crucial for system administrators and users alike. For those operating on Debian-based systems, understanding how to Change Hostname on Debian 12 Bookworm or the older stable releases of Debian 11 Bullseye or Debian 10 Buster is essential.

For those unfamiliar with hostnames, it is, in essence, a distinct label assigned to a computer or device within a network. It serves as an identifier, ensuring each device on the network can be uniquely recognized. This guide will delve into the steps required to modify the hostname on your Debian system using the command line, ensuring efficient device identification and customization.

Method 1: Change hostname with “hostnamectl”

The process starts with launching the terminal to change the hostname in Debian. To do so, you can either click on the terminal icon located in the application launcher.

After opening the terminal, you must execute the command “sudo hostnamectl set-hostname new_hostname” to modify the hostname. Remember to replace “new_hostname” with the desired name you want to assign to your Debian device.

sudo hostnamectl set-hostname new-hostname

To modify the hostname of the Debian system, replace “new_hostname” in the “sudo hostnamectl set-hostname new_hostname” command with the desired hostname. This command will change the hostname of your Debian device to the specified value.

As an example, executing the following command will modify the hostname to “debian-linux”:

sudo hostnamectl set-hostname debian-linux

After you modify the hostname, close the terminal and open a new command line terminal to verify the successful application of the changes.

Method 2: Change Hostname with Hostname File

Another way to modify the Debian hostname is to edit the “/etc/hostname” file manually. By changing the hostname value in this file, you can set a new name for your system. First, open the hostname file with the nano text editor:

sudo nano /etc/hostname

Replace the current hostname value with the new desired name you want to assign to your Debian device.

For example, you could employ the hostname:

debian-linux

Apply the changes you made to your Debian system’s hostname. After you restart, the system will update and use the new hostname.

reboot

Conclusion

In summary, you can modify the hostname on Debian using the “hostnamectl set-hostname” command or directly editing the “/etc/hostname” file. Most users prefer the “hostnamectl set-hostname” command because it’s efficient and user-friendly. But if your system doesn’t support this command, you can always edit the “/etc/hostname” file. After you make the changes, restart the system to activate the new hostname.

Leave a Comment