Debian Jessie comes with systemd
. The recommendation to set the hostname is using hostnamectl for systemd. However, this command does not work (even to display the current hostname) on the Debian Jessie image booted on EC2:
sudo hostnamectl
sudo: unable to resolve host ip-172-30-0-17
Failed to create bus connection: No such file or directory
So I tried to go ahead with Debian's recommendation here.
echo "myhostname" > /etc/hostname
echo "127.0.0.1 myhostname" >> /etc/hosts
/etc/init.d/hostname.sh start
/etc/init.d/networking force-reload
However, after logging out and logging in again, the hostname does not change. It does however change after a reboot, but that is not desirable to me.
This method used to work in Debian Wheezy.
Any help with getting this right is appreciated.