Score:0

What is the purpose of the line 127.0.1.1 in the file /etc/hosts in Ubuntu?

pg flag

This question is linked to this other question which explains that to change the hostname of a system with lubuntu 22.04 installed I have to modify 2 files:

  • /etc/hostname (by the command nmcli)
  • /etc/hosts

While I'm thinking that I have understood the scope of the file /etc/hostname, I don't know what is the scope of the presence of the line 127.0.1.1 <HOSTNAME> in the file /etc/hosts.

The question is:
What is the purpose of the line 127.0.1.1 in the file /etc/hosts ?

muru avatar
us flag
It's basically so that your hostname resolved to *something*, which may not always be the case if this entry is absent and DNS resolution is attempted. `sudo` is one tool famous for errors about problems with resolving the local system's hostname.
frankfalse avatar
pg flag
Thank you. In other Linux system I usually think that the hostname is connected to 127.0.0.1 and I have not noted that existence of a configuration which links the hostname to 127.0.1.1. May be I wasn't paying attention!
muru avatar
us flag
In most `/etc/hosts` files I have seen, usually `127.0.0.1` is set to `localhost`, and some other loopback address (in this case `127.0.1.1`, but I have seen others) is used for the hostname
mangohost

Post an answer

Most people don’t grasp that asking a lot of questions unlocks learning and improves interpersonal bonding. In Alison’s studies, for example, though people could accurately recall how many questions had been asked in their conversations, they didn’t intuit the link between questions and liking. Across four studies, in which participants were engaged in conversations themselves or read transcripts of others’ conversations, people tended not to realize that question asking would influence—or had influenced—the level of amity between the conversationalists.