How do I change the hostname on an Ubuntu Core system?

I just installed Ubuntu Core on my Raspberry Pi 3 and I would like to use a name other than localhost.localdomain.

How would I do this? Are there special considerations to take into account?


Solution 1:

Since Ubuntu 13.10 you should use hostnamectl:

sudo hostnamectl set-hostname 'new-hostname'

The advantages are numerous including one command to make all those changes reducing problems with typos or sudo (you can easily break sudo if you make mistakes) and no reboot is required.

See also How do I change the computer name?