More than one person in the past year has had a problem that sounded like this: "I have a liquid cooled super computer but this one application takes, like, a minute to load. What's the big deal? Do I need more GBs??"
The solution to this problem is to add the hostname for the computer into the "/etc/hosts" file on the line that has "127.0.0.1". Here are two real world examples: Post 1, Post 2 I think the reason it's uncommon for people to make this change to the "hosts" file is because of what's in the Beginner's Guide, which states:
Note: There is no need to edit /etc/hosts.
Way back when I installed Arch Linux, the Beginner's Guide had different advice, so my "hosts" file has the change. According to a post by WonderWoofy, the "hosts" file might be obsolete. But clearly, modifying the "hosts" file has a very real and important effect on some user's systems.
So, what is the actual state of the "/etc/hosts" file? Shall I go ahead and change the Beginner's Guide to say that the file does need to be changed?
...I don't mind leaving it, because every time someone comes to the forums with this problem it allows me to easily bump my post count.
Indeed, nss-myhostname was supposed to make modifying the hosts file unnecessary (this functionality is now provided in the systemd package). But admittedly, I have seen a number of threads around here where adding your hostname apparently solves various issues. For me, it has not (yet?) been necessary, but I have now become hesitant to fully stand by my previous statement that this modification is not at all necessary.
In the 'Overview' section of this page it explains why this is supposed to be the case. I remember seeing this being discussed on a mailing list somewhere though and that is where I originally got the info. I can't find it at the moment...
In my case, after laptop is woken up from sleep, Raspberry Pi fails to resolve hostname based nfs mount. It works before suspend. Editing hostname fixed it.
For some reason, I have the following in my /etc/hosts:
127.0.0.1 my_hostname localhost ::1 my_hostname localhost
The second one is the IPv6 equivalent of 127.0.0.1 (as described e.g. here). I'm not sure why/when I added this, does anybody know if or why it is necessary?
@karkhaz, I'm not sure why you would have that. The old instructions (that are being discussed in this thread) told you to do something like:
% cat /etc/hosts 127.0.0.1 localhost.localdomain localhost my_hostname ::1 localhost.localdomain localhost my_hostname