If you have Cloud cloud-ini installed you will have to edit
sudo nano /etc/cloud/cloud.cfg
to preserve your new hostname.
# This will cause the set+update hostname module to not operate (if true) preserve_hostname: true
When that is done, run the rename command
sudo hostnamectl set-hostname new-hostname
Edit /etc/hosts so it corresponds with your new hostname
127.0.0.1 localhost 127.0.0.1 new-hostname # The following lines are desirable for IPv6 capable hosts ::1 localhost ip6-localhost ip6-loopback ff02::1 ip6-allnodes ff02::2 ip6-allrouters
You can verify your changes by running
At last, reboot and it should show the correct hostname.