nerdexam
LPI

102-400 · Question #183

Which of the following looks like a correct entry in the /etc/hosts file?

The correct answer is D. 127.0.0.1 localhost.localdomain localhost. See the full explanation below for the reasoning.

Question

Which of the following looks like a correct entry in the /etc/hosts file?

Options

  • Alocalhost 127.0.0.1 localhost.localdomain
  • Blocalhost.localdomain localhost 127.0.0.1
  • Clocalhost localhost.localdomain 127.0.0.1
  • D127.0.0.1 localhost.localdomain localhost
  • Elocalhost.localdomain 127.0.0.1 localhost

How the community answered

(19 responses)
  • A
    16% (3)
  • B
    5% (1)
  • C
    5% (1)
  • D
    74% (14)

Community Discussion

5
Viktor S.Viktor S.May 20, 2026

D is correct because /etc/hosts entries always lead with the IP address, followed by the canonical hostname, then any aliases. The file's parser expects that first field to be an address, so anything that puts a hostname first is just plain wrong.

29
Nina C.Nina C.May 23, 2026

Right, and a quick thing to keep in mind for the exam is that the same IP-first rule holds for the IPv6 loopback entry too, so if they show you a question with "::1 localhost" it follows the exact same format and is not a trick.

0
Ola B.Ola B.May 16, 2026

The format of /etc/hosts always puts the IP address first, then the hostnames that map to it, so D is the one that looks right to me. If you spin up any Linux box and open that file, you will see that pattern immediately, no guessing required. The reason options like A, B, C, and E trip people up is that they flip the order, putting hostnames before the address, which the resolver simply will not parse the way you expect. Quick lab check: cat /etc/hosts on any system you have handy and compare it against each option. Here is what I am curious about though, do you know why there are two names listed after the IP in option D, and what the difference between localhost and localhost.localdomain actually means in terms of how the system uses them?

3
Nina C.Nina C.May 9, 2026

I keep going back to A on this one because when I think about how you read an address out loud, you say the name first and then the numbers, like saying your street name before the zip code, so "localhost 127.0.0.1 localhost.localdomain" just reads the most naturally to me and matches how I picture the file in my head from the study guide.

-1
Ola B.Ola B.May 11, 2026

Hey Nina, the hosts file actually requires the IP address to come first on each line, so D puts 127.0.0.1 before the hostnames, which is exactly what the parser expects when it reads the file at boot. Spin up a Linux VM and cat /etc/hosts yourself and you will see that pattern on every single line.

0
Full 102-400 Practice