For older versions of Ubuntu, many of the tutorials online show you how to edit your server’s hostname by simply editing /etc/hostname and then restarting the service with “service hostname restart”.
However, attempting this on a 16.04 Ubuntu Server build will most likely fail with the following error message:
Failed to restart hostname.service: Unit hostname.service is masked.
As it turns out, the new way of changing your hostname on systems running systemd (i.e. Ubuntu 16.04) requires you to use the hostnamectl command, meaning that to set your new hostname you need to run:
sudo hostnamectl set-hostname NEWNAME
(Where obviously NEWNAME is the new/desired hostname that you want to use).
You can check that the change has been affected by running:
Worth jotting down here for future reference.