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。