Linux penguin logo sitting in front of a server warehouse

How to change the hostname of a Linux server

This post describes how to change a hostname on a Debian 7 Linux server, however it will work on most other Linux distributions too.

Switch to root

sudo -i

Change the /etc/hostname file

echo 'new.host.name' > /etc/hostname

Restart the hostname service

/etc/init.d/hostname.sh start

That’s it. The host name is now updated.