How to Change Hostname on Debian 13 (Trixie)

The Hostname is the name your system uses to identify itself on the network. This guide shows how to change it temporarily or permanently.

Check Current Hostname

hostnamectl

Output example:

root@server:~# hostnamectl
 Static hostname: server
       Icon name: computer-vm
         Chassis: vm 🖴
      Machine ID: 14d53f9ab433443fa523e13e53e556af
         Boot ID: 54f79afe97004032ad27297371c6f8cd
    Product UUID: 6bd1359e-9173-4ee4-8d2b-bbedd55d16f7
  Virtualization: kvm
Operating System: Debian GNU/Linux 13 (trixie)
          Kernel: Linux 6.12.35+deb13-amd64
    Architecture: x86-64
 Hardware Vendor: Red Hat
  Hardware Model: KVM
Firmware Version: 1.16.0-4.module_el8.9.0+3659+9c8643f3
   Firmware Date: Tue 2014-04-01
    Firmware Age: 11y 3month 3w 3d

Change Hostname (Temporarily and Permanently)

To change the system hostname (e.g., to webserver1):

hostnamectl set-hostname webserver1

No reboot is required. You can verify:

hostnamectl

Update /etc/hosts File

Edit the /etc/hosts file to map the hostname to 127.0.1.1:

nano /etc/hosts

Update the line like this:

127.0.1.1    webserver1

Save and exit.

Step 4: Apply Changes (If Needed)

The changes apply immediately for most use cases. You can test:

hostname

And to fully refresh system references, you can reboot:

reboot

Conclusion

Your system now uses the new hostname.
It will persist across reboots and will appear in terminal prompts, logs, and networking.


CrownCloud - Get a SSD powered KVM VPS at $4.5/month!
Use the code WELCOME for 10% off!

1 GB RAM / 25 GB SSD / 1 CPU Core / 1 TB Bandwidth per month

Available Locations: LAX | MIA | ATL | FRA | AMS