nsswitch.conf(5)

๐Ÿ’– nsswitch.conf โ€” the Name Service Switch configuration file

okay bestie, pull up a chair ๐Ÿซถ this one is nsswitch.conf(5) from the File Formats Manual, and honestly? it's the file that decides where your computer asks when it wants to know who somebody is. no cap.


โœจ NAME โœจ

nsswitch.conf โ€” Name Service Switch configuration file ๐ŸŒธ


๐ŸŒˆ DESCRIPTION ๐ŸŒˆ

The Name Service Switch (NSS) configuration file, /etc/nsswitch.conf, is used by the GNU C Library and some other applications to figure out which sources to pull name-service info from โ€” across a whole bunch of categories โ€” and in what order. Every category of information has a database name. it's giving air traffic control for your lookups ๐Ÿ’…

The file is plain ASCII text, and the columns get separated by spaces or tab characters. Column one = the database name. The rest of the columns describe the order of sources to query, plus a limited set of actions that can be performed based on the lookup result. periodt.

These are the databases the GNU C Library understands ๐Ÿ‘‘

  • aliases โ€” Mail aliases, used by getaliasent(3) and related functions.
  • ethers โ€” Ethernet numbers.
  • group โ€” Groups of users, used by getgrent(3) and related functions.
  • hosts โ€” Host names and numbers, used by gethostbyname(3) and related functions.
  • initgroups โ€” Supplementary group access list, used by the getgrouplist(3) function.
  • netgroup โ€” Network-wide list of hosts and users, used for access rules. C libraries before glibc 2.1 supported netgroups only over NIS.
  • networks โ€” Network names and numbers, used by getnetent(3) and related functions.
  • passwd โ€” User passwords, used by getpwent(3) and related functions.
  • protocols โ€” Network protocols, used by getprotoent(3) and related functions.
  • publickey โ€” Public and secret keys for Secure_RPC used by NFS and NIS+.
  • rpc โ€” Remote procedure call names and numbers, used by getrpcbyname(3) and related functions.
  • services โ€” Network services, used by getservent(3) and related functions.
  • shadow โ€” Shadow user passwords, used by getspnam(3) and related functions.

The GNU C Library ignores databases with unknown names. and some applications are out here using that on purpose to implement special handling for their own lil databases ๐Ÿ™ˆ for example, sudo(8) consults the sudoers database. Delegation of subordinate user/group IDs can be configured using the subid database โ€” go peek at subuid(5) and subgid(5) for the deets.

Here's an example /etc/nsswitch.conf file, iconic behavior, look at her ๐Ÿ’–:

passwd:         compat
group:          compat
shadow:         compat

hosts:          dns [!UNAVAIL=return] files
networks:       nis [NOTFOUND=return] files
ethers:         nis [NOTFOUND=return] files
protocols:      nis [NOTFOUND=return] files
rpc:            nis [NOTFOUND=return] files
services:       nis [NOTFOUND=return] files

First column = the database name. The remaining columns specify:

  • One or more service specifications, for example "files", "db", or "nis". The order of the services on the line determines the order in which those services will be queried, in turn, until a result is found. ๐Ÿฆ‹
  • Optional actions to perform if a particular result is obtained from the preceding service, for example "[NOTFOUND=return]".

Now โ€” the service specifications supported on your system depend on the presence of shared libraries, so they're extensible. Libraries called /lib/libnss_SERVICE.so.X will provide the named SERVICE. On a standard installation, you can use "files", "db", "nis", and "nisplus". For the hosts database, you can additionally specify "dns". For the passwd, group, and shadow databases, you can additionally specify "compat" (see Compatibility mode below). The version number X may be 1 for glibc 2.0, or 2 for glibc 2.1 and later. On systems with additional libraries installed, you may have access to further services such as "hesiod", "ldap", "winbind", and "wins". the vibes are truly extensible โœจ

An action may also be specified following a service specification. The action modifies the behavior following a result obtained from the preceding data source. Action items take the general form:

[STATUS=ACTION]
[!STATUS=ACTION]

where

STATUS => success | notfound | unavail | tryagain
ACTION => return | continue | merge

The ! negates the test, matching all possible results except the one specified. The case of the keywords is not significant โ€” she's flexible like that ๐Ÿ’…

The STATUS value is matched against the result of the lookup function called by the preceding service specification, and can be one of:

  • success โ€” No error occurred and the requested entry is returned. The default action for this condition is "return".
  • notfound โ€” The lookup succeeded, but the requested entry was not found. The default action for this condition is "continue".
  • unavail โ€” The service is permanently unavailable. This can mean either that the required file cannot be read, or, for network services, that the server is not available or does not allow queries. The default action for this condition is "continue".
  • tryagain โ€” The service is temporarily unavailable. This could mean a file is locked or a server currently cannot accept more connections. The default action for this condition is "continue".

The ACTION value can be one of:

  • return โ€” Return a result now. Do not call any further lookup functions. However, for compatibility reasons, if this is the selected action for the group database and the notfound status, and the configuration file does not contain the initgroups line, the next lookup function is always called, without affecting the search result. (yes bestie that's a whole mouthful, but it's important ๐Ÿ˜ญ)
  • continue โ€” Call the next lookup function.
  • merge โ€” [SUCCESS=merge] is used between two database entries. When a group is located in the first of the two group entries, processing will continue on to the next one. If the group is also found in the next entry (and the group name and GID are an exact match), the member list of the second entry will be added to the group object to be returned. Available since glibc 2.24. Note that merging will not be done for getgrent(3) nor will duplicate members be pruned when they occur in both entries being merged. ๐ŸŒธ

๐ŸŽ€ Compatibility mode (compat) ๐ŸŽ€

The NSS "compat" service is similar to "files" except that it additionally permits special entries in corresponding files for granting users or members of netgroups access to the system. The following entries are valid in this mode:

For passwd and shadow databases:

  • +user โ€” Include the specified user from the NIS passwd/shadow map.
  • +@netgroup โ€” Include all users in the given netgroup.
  • -user โ€” Exclude the specified user from the NIS passwd/shadow map.
  • -@netgroup โ€” Exclude all users in the given netgroup.
  • + โ€” Include every user, except previously excluded ones, from the NIS passwd/shadow map.

For group database:

  • +group โ€” Include the specified group from the NIS group map.
  • -group โ€” Exclude the specified group from the NIS group map.
  • + โ€” Include every group, except previously excluded ones, from the NIS group map.

By default, the source is "nis", but this may be overridden by specifying any NSS service except "compat" itself as the source for the pseudo-databases passwd_compat, group_compat, and shadow_compat. ๐Ÿฆ‹


๐Ÿ“‚ FILES ๐Ÿ“‚

A service named SERVICE is implemented by a shared object library named libnss_SERVICE.so.X that resides in /lib. ๐Ÿ‘‘

  • /etc/nsswitch.conf โ€” NSS configuration file.
  • /lib/libnss_compat.so.X โ€” implements "compat" source.
  • /lib/libnss_db.so.X โ€” implements "db" source.
  • /lib/libnss_dns.so.X โ€” implements "dns" source.
  • /lib/libnss_files.so.X โ€” implements "files" source.
  • /lib/libnss_hesiod.so.X โ€” implements "hesiod" source.
  • /lib/libnss_nis.so.X โ€” implements "nis" source.
  • /lib/libnss_nisplus.so.X โ€” implements "nisplus" source.

The following files are read when "files" source is specified for the respective databases:

  • aliases โ€” /etc/aliases
  • ethers โ€” /etc/ethers
  • group โ€” /etc/group
  • hosts โ€” /etc/hosts
  • initgroups โ€” /etc/group
  • netgroup โ€” /etc/netgroup
  • networks โ€” /etc/networks
  • passwd โ€” /etc/passwd
  • protocols โ€” /etc/protocols
  • publickey โ€” /etc/publickey
  • rpc โ€” /etc/rpc
  • services โ€” /etc/services
  • shadow โ€” /etc/shadow

๐Ÿ“ NOTES ๐Ÿ“

Starting with glibc 2.33, nsswitch.conf is automatically reloaded if the file is changed. ๐ŸŽ‰ In earlier versions, the entire file was read only once within each process. If the file was later changed, the process would just keep using the old configuration. ๐Ÿ’€ so if you're on an ancient glibc, restart the thing. iykyk.

Traditionally, there was only a single source for service information, often in the form of a single configuration file (e.g., /etc/passwd). However, as other name services, such as the Network Information Service (NIS) and the Domain Name Service (DNS), became popular, a method was needed that would be more flexible than fixed search orders coded into the C library. The Name Service Switch mechanism, which was based on the mechanism used by Sun Microsystems in the Solaris 2 C library, introduced a cleaner solution to the problem. main character energy fr fr ๐ŸŒŸ


๐Ÿ‘€ SEE ALSO ๐Ÿ‘€

getent(1), nss(5)


and that's the whole page, bestie ๐Ÿซถ this was Linux man-pages 6.20, dated 2026-02-08 โ€” stay slaying those lookups, nsswitch.conf(5) out ๐Ÿ’–โœจ๐ŸŽ€

๐Ÿ“ฆ where this page comes from
  • arch rolling: man-pages 6.20-1 ยท BSD-2-Clause AND BSD-3-Clause AND BSD-4.3TAHOE AND BSD-4-Clause-UC AND GPL-1.0-or-later AND GPL-2.0-only AND GPL-2.0-or-later AND GPL-3.0-or-later AND LGPL-3.0-linking-exception AND LGPL-3.0-or-later AND LicenseRef-Public-Domain AND LicenseRef-UltraPermissive AND Linux-man-pages-1-para AND Linux-man-pages-copyleft AND Linux-man-pages-copyleft-2-para AND Linux-man-pages-copyleft-var AND MIT AND Spencer-94
  • nixpkgs unstable: man-pages 6.20
  • ๐Ÿ“œ the page's license: GPL-2.0-or-later
  • ๐Ÿ’– girlified by deepseek-ai/DeepSeek-V4.1-Flash on : a language model's rewrite of the original, under its terms