Question

/etc/hosts best practices?

Posted March 23, 2018 2.5k views
Linux Basics CentOS

I have renamed my droplet from the default centos-s-2vcpu-blah to my FQDN, and I see that the PTR record was auto-created accordingly.

I see that my bash prompt is still: [bob@centos-s-2vcpu-blah ~]

So I look in /etc/hosts and I find this (excluding commented lines and those for IPv6, and where I have changed my FQDN to example.com):

127.0.0.1 centos-s-2vcpu-blah centos-s-2vcpu-blah
127.0.0.1 localhost.localdomain localhost
127.0.0.1 localhost4.localdomain4 localhost4
159.89.111.111 www.example.com example.com

Is it recommended to edit the first line to replace centos-s-2vcpu-blah above to my FQDN?
Should I leave alone the 2nd and 3rd lines?
If I do edit the first line to my FQDN, will my bash prompt change to show my FQDN?

Or do the 127.0.0.1 entries not really matter? And I can set it to whatever I like my bash prompt to say purely for the purpose of identifying to myself which Putty window is which, if I have a Putty window open to each of my many droplets.

These answers are provided by our Community. If you find them useful, show some love by clicking the heart. If you run into issues leave a comment, or add your own answer to help others.

1 answer

You’re best off to run the hostname command as root (check hostname -h for full command).
Give the droplet a reboot, if the /etc/hosts still has old entries, then give it an edit.

Submit an Answer