I am trying to change the hostname to host01 on an instance that was is using the RightImage_CentOS_5.4_x64_v5.6 - 11H2.a1 [rev 11] MCI.

So I set the /etc/hosts file to: localhost localhost.localdomain host01  

and set the /etc/sysconfig/network file:


and rebooted.

After the reboot, everything looks good. The hostname is changed:

$ /bin/hostname

However, a new file appeared in the system /etc/hostname with, the following content:


The /etc/hosts host file looks like this: localhost localhost.localdomain host01 ip-10-76-249-192.ec2.internal ip-10-76-249-192  

After reboot, if I drop into an other user, the hostname will change back:

$ hostname

Does anybody has any idea why this is happening and how stop this?

  • Is there anything in /var/log/audit? – Bart De Vos Jun 11 '11 at 9:01

Rightscale's FAQ recommends you use an rc script to change the hostname using the hostname command.


  • The problem is that hostname command only changes until the system is rebooted. – tmx Jun 11 '11 at 19:07
  • Which is part of the recommendation, if you use the /etc/rc.local startup script it will reset itself post install after the Rightscale/EC2 auto name change occurs. There will be a brief moment where it would be set to the dynamic name, but then it will revert just as the init scripts complete. – Ori Jun 11 '11 at 20:30

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.