How to set the hostname for a Debian Jessie system?
Solution 1:
Found the problem. The base AMI on EC2 for Debian Jessie, does not have dbus installed. hostnamectl seems to need dbus. So the fix is to:
apt-get update && apt-get install -y dbus
And then:
hostname=myname
echo "127.0.0.1 $hostname" >> /etc/hosts
hostnamectl set-hostname "$hostname"
echo "$hostname" > /etc/hostname # uneeded
This worked.
Solution 2:
To change the hostanme of your EC2 host, you must follow the steps bellow :
- Login as root :
$: sudo su -
- Install dbus :
$: apt-get update && apt-get install -y dbus
- Setup hostname :
hostnamectl set-hostname <HOSTNAME>
Make sure to change <HOSTNAME>
with the hostname you want to set.