Change Hostname Amazon Linux
Here’s how to make a hostname stick on Amazon Linux.
Set preserve_hostname to true in /etc/cloud/cloud.cfg.
<pre lang="bash">
preserve_hostname: true
Set the hostname in /etc/sysconfig/network.
<pre lang="bash">
HOSTNAME=server.domain.com
NETWORKING=yes
NOZEROCONF=yes
Reboot the server to make sure hostname sticks after a reboot.
<pre lang="bash">
shutdown -r now
Login to confirm hostname sticks.