Which THREE statements about /etc/hosts on a glibc system are correct? (Choose three.)

LPIC-1 Exam 102-500, objective 109. Networking fundamentals hard

Machine-checked — no person has signed for it. This question was read against the source cited below by an automated pass, which found no contradiction. That is a weaker claim than it sounds: the same kind of process wrote the question, so it can confirm its own mistake.

Treat it as a good draft rather than as settled fact, and read the source below before you rely on it. It is not used in mock exams here — only questions a person has signed for are.

How these questions are written — where each question comes from, what the verification ledger records, and what happens when one is found wrong.

The options

Choose 3.

Correct A line starts with an IP address, followed by the canonical hostname and then any number of aliases, all separated by whitespace.

Correct. That is the field order of the file: address first, canonical name second, aliases after it.

Correct Whether the file is consulted at all, and whether it wins over DNS, is decided by the hosts line of /etc/nsswitch.conf.

Correct. The file is reached through the files NSS source, and its position on that line relative to dns or resolve decides precedence.

Correct IPv6 addresses may be used, so an entry such as `::1 localhost ip6-localhost` is valid.

Correct. The address field takes either family; a standard file ships with both 127.0.0.1 and ::1 entries.

Not correct dig consults the file before sending a query, so an entry there changes what dig reports.

Wrong. dig is a DNS client and talks only to name servers. It never reads /etc/hosts, which is why dig and ping can disagree about a name.

Not correct Comments are introduced by a semicolon, matching DNS zone file syntax.

Wrong. In /etc/hosts a comment runs from a # to the end of the line. The semicolon convention belongs to zone files, not to this one.

Not correct An edit only takes effect once systemd-resolved or nscd has been restarted.

Wrong. The file is read on demand during lookups, so an edit applies to the next resolution. A caching layer may hold an older answer, but no restart is required for the file itself.

Why

/etc/hosts is a flat table of address, canonical name and optional aliases, one entry per line, with # starting a comment and both address families permitted. It is reached only through the files source of the hosts database in /etc/nsswitch.conf, so its authority depends entirely on where files sits on that line. The distinction worth carrying is that NSS-based lookups (getaddrinfo, getent, ordinary applications) see the file, while DNS clients such as dig and host do not.

Where this comes from

Cited
manual page hosts(5)

Practise this

Reading one question is not practice. The trainer will draw a short set from objective 109 and space the ones you get wrong.

Practise LPIC-1 Exam 102-500

More questions on this objective

All questions on Networking fundamentals

Practise LPIC-1 Exam 102-500