Skip to content

Changing the Hostname in Debian

Updates & News  ·  Christopher Sakel  ·   ·  Updated on  ·  1 min Reading time

In this blog article I want to show you how to change your hostname in Debian 8/9/10/11.

First we log in to the server via SSH, for example with Putty.
While the system is running, we can use the following command:
root@testserver ~ # hostname NewHostname

To make the hostname persist, we need to edit the following file with an editor, in our case nano: root@testserver ~ # nano /etc/hostname


There we now find our current hostname and can change it.

After entering the desired hostname, we can confirm everything with CTRL+X & CTRL+Y.

Frequently asked questions

How do I change the hostname temporarily on a running Debian system?
Log in via SSH and run `hostname NewHostname`.
How do I make the hostname change persist after a reboot?
Edit `/etc/hostname` with an editor like nano, replace the current entry with your new hostname, and save.
Which Debian versions does this apply to?
Debian 8, 9, 10, and 11.