What is the purpose of the nsswitch.conf file?

A. It is used to configure where the C library looks for system information such as host names and user passwords.
B. It is used to configure network protocol port numbers such as for HTTP or SMTP.
C. It is used to configure LDAP authentication services for the local system.
D. It is used to configure which network services will be turned on during the next system boot.

题解

部份 GNU C 语言的函数库会根据本地端系统的设置不同而有不同的运作方式,像是 getaliasent、gethostbyname、getnetent 等等的函数。GNU C 语言的函数库会使用 NSS (Name Service Switch)来读取系统的数据库,数据库名称列表如下:
  • aliases
  • ethers
  • group
  • hosts
  • initgroups
  • netgroup
  • networks
  • passwd
  • protocols
  • publickey
  • rpc
  • services
  • shadow

NSS 的设置档「/etc/nsswitch.conf」决定了该数据库名称的数据取得的来源和顺序。如「files」表示来源为文件(设置档)、「db」表示来源为数据库、「dns」表示来源为网域名称服务器,而「compat」则有点像是「files」但同时能使用文件来过滤 NIS 来的数据。

所以答案是选项 A。