![How to Change the Hostname in Debian 12 BookWorm](https://i0.wp.com/www.linuxjournal.com/sites/default/files/nodeimage/story/how-to-change-the-hostname-in-debian-12-bookworm.jpg?resize=850%2C500&ssl=1)
Introduction
In the vast realm of networked computers, each device needs a unique identifier—a name that allows it to be distinguishable from the crowd. This unique identifier is known as the “hostname.” Whether you are working in a large corporate network or simply tinkering with a personal Linux box, you might find yourself needing to change this hostname at some point. This comprehensive guide walks you through the process of changing the hostname in Debian 12 BookWorm, one of the latest iterations of the popular Linux distribution Debian.
Prerequisites
Before diving into the nitty-gritty, ensure you have the following:
- Access to a Terminal: You can access the terminal through your GUI or via SSH if you’re working remotely.
- Superuser or
sudo
Privileges: Administrative access is necessary to make system-wide changes. - Basic Understanding of Linux Command Line: Knowing how to navigate the terminal will be beneficial.
- Installed Instance of Debian 12 BookWorm: The instructions are tailored for this specific version.
Terminology
To make sure we’re on the same page, let’s clarify some terminology:
- Hostname: A label assigned to a machine on a network.
- Superuser: The administrator with full access to the Linux system.
sudo
: Command that allows permitted users to execute a command as a superuser./etc/hostname
and/etc/hosts
: Configuration files storing hostname information.
Backup Current Settings
It’s always prudent to backup important configurations before making any changes. Open the terminal and run:
cp /etc/hostname /etc/hostname.bak cp /etc/hosts /etc/hosts.bak
This creates backup copies of your current hostname and hosts files.
Method 1: Using the hostnamectl
Command
Step 1: Check Current Hostname
To see your current hostname, run the following command:
hostnamectl
Step 2: Change the Hostname
To change your hostname, execute:
sudo hostnamectl set-hostname new-hostname
Replace new-hostname
with your desired hostname. For instance, to change the hostname to “mydebian,” you’d run:
sudo hostnamectl set-hostname mydebian
Step 3: Verify the Changes
Use the hostnamectl
command again to check if the hostname has been updated:
hostnamectl
Powered by WPeMatico
Go to Source
Author: George Whittaker