AWS EC2 – Change Hostname

Set a CNAME redirection to the EC2 then execute this code


sudo hostnamectl set-hostname newhostname.domain.net

sudo reboot

hostname