Change hostname
Updating the Hostname on Debian 12¶
About this guide
This guide outlines how to change the hostname on a Debian 12 system using the terminal.
1. Set the New Hostname¶
Run the following command to set a new hostname:
Replace <new-hostname>
with your desired hostname.
2. Update /etc/hosts
¶
Open the /etc/hosts
file to reflect the new hostname:
Ensure the line referencing 127.0.1.1
is updated, for example:
Why update /etc/hosts?
This ensures proper hostname resolution for local services and prevents potential issues with networking or sudo.
3. Verify the Change¶
Confirm the hostname was successfully changed:
Expected output will include:
A reboot is not required, but you may log out and back in to see the hostname updated in your shell prompt.