I have successfully changed the hostname of my Ubuntu machine, though whenever I restart it, I need to run this command to access it using host name
sudo /etc/init.d/hostname.sh start
This is what I used to do the change:
# take care of "hostname" command and editing "/etc/hostname"
hostnamectl set-hostname <new.hostname>
# Edit "/etc/hosts"
127.0.1.1 <new.hostname>
How can I make this permanent?
Best Answer
I followed [these instructions] and it worked even after restart the machine.
Summary:
Also you should recreate your ssh keys on your machine:
Just in case, check references of your old hostname on /etc and fix it: