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.