/etc/hosts best practices?

March 23, 2018 480 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): centos-s-2vcpu-blah centos-s-2vcpu-blah localhost.localdomain localhost localhost4.localdomain4 localhost4 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 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.

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.

  • I ran hostname, and rebooted. There was no change to /etc/hosts .
    What manual edits are now needed?

Have another answer? Share your knowledge.