Debian /etc/hostname not flowing to /etc/hosts

Ricky Nguyen
Ricky Nguyen used Ask the Experts™
on
Hi Experts,

I'm new to Linux and require your assistance.

I was attempting to change my hostname from debian to ns1. This change used to automatically flow from the hostname file to the hosts file by itself. I didn't see it change this time after a reboot.

The only thing that has changed since my recent configuration is the interfaces setting, from DHCP to Static. Could this be the cause?

The reason why I'm asking is because I don't want to have to look for all the files that are affected by the change in hostname file and manually make the edit.

Is this normal? If the only dependency on the hostname file is the hosts file then I don't have a problem with making the manual edit but if its affecting others, then I'll like some help with reconfiguring the link between the two files.

I hope that makes sense.

Regards,
Ric
Comment
Watch Question

Do more with

Expert Office
EXPERT OFFICE® is a registered trademark of EXPERTS EXCHANGE®
for changing hostname you just require to change the host file and in /etc/hosts file....

1. sudo gedit /etc/hostname
2. Save the file with the hostname you like to set
3. sudo /etc/init.d/hostname.sh start



http://adminuser.wordpress.com/2008/02/10/change-hostname-permanently-on-debian-or-ubuntu/

Author

Commented:
Hi, thanks for the prompt reply!

So you're saying I'll have to edit both the hostname and hosts file each time?

Any ideas as to why hostname used to update the hosts file automatically?

Regards,
Ric
Host file has entry like below and it require to update the file  so that the machine can be resolved by ip address again FQDN
127.0.0.1 localhost
127.0.1.1 <host_name>.<domain_name> <host_name>

Author

Commented:
Hi Anuroopsundd,

I understand how the hosts file works, so that is not my issue. What I don't understand is whether the hostname file is linked in anyway to the hosts file.

Is it possible for the hosts file to be automatically updated by the hostname file.

Eg. Hostname change from debian  to ns1 and thefore
     Hosts file change respectively,
From 127.0.1.1 debian.mydomain.com debian
To      127.0.1.1 ns1.mydomain.com ns1

Does debian do this under any circumstance besides custom scripting?

Regards
Ric
Commented:
hosts file will not be changed due to changes in hostname file. it is a passive file.

Author

Commented:
I could have sworn I saw the the hostname move respectively in each file, but anyway, who am I to argue. Thanks

Do more with

Expert Office
Submit tech questions to Ask the Experts™ at any time to receive solutions, advice, and new ideas from leading industry professionals.

Start 7-Day Free Trial