Difficulty: Easy
Correct Answer: /etc/services
Explanation:
Introduction / Context:
Classic UNIX networking stacks map human-readable service names (like http, smtp, ssh) to well-known port numbers. System libraries consult a canonical file for these mappings, enabling tools and daemons to specify services symbolically.
Given Data / Assumptions:
Concept / Approach:
The file /etc/services lists services with their port/protocol pairs (for example, ssh 22/tcp). C library functions like getservbyname consult this database. While many systems now prefer systemd socket activation or stand-alone daemons, /etc/services remains the canonical reference for service names and ports.
Step-by-Step Solution:
Verification / Alternative check:
Check nsswitch behavior in /etc/nsswitch.conf to ensure the services database is consulted locally. Validate resolution using getent services servicename.
Why Other Options Are Wrong:
b: /etc/nsorder is not standard across modern systems.
c: /etc/nsswitch.conf configures name service lookup order; it does not list service-port pairs.
d: /etc/hosts maps hostnames to IP addresses, not ports.
e: Not applicable because /etc/services is correct.
Common Pitfalls:
Confusing service names with daemon binary names; assuming /etc/services changes active daemon ports (it is informational, not authoritative for running daemons); forgetting protocol distinctions (tcp vs udp).
Final Answer:
/etc/services
Discussion & Comments