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.