{
    "mode": "man",
    "parameter": "nsswitch.conf",
    "section": "5",
    "url": "https://www.chedong.com/phpMan.php/man/nsswitch.conf/5/json",
    "generated": "2026-11-20T11:05:44Z",
    "sections": {
        "NAME": {
            "content": "nsswitch.conf - Name Service Switch configuration file\n",
            "subsections": []
        },
        "DESCRIPTION": {
            "content": "The  Name  Service  Switch (NSS) configuration file, /etc/nsswitch.conf, is used by the GNU C\nLibrary and certain other applications to determine the sources from which  to  obtain  name-\nservice  information  in a range of categories, and in what order.  Each category of informa‐\ntion is identified by a database name.\n\nThe file is plain ASCII text, with columns separated by spaces or tab characters.  The  first\ncolumn  specifies  the database name.  The remaining columns describe the order of sources to\nquery and a limited set of actions that can be performed by lookup result.\n\nThe following databases are understood by the GNU C Library:\n\naliases     Mail aliases, used by getaliasent(3) and related functions.\n\nethers      Ethernet numbers.\n\ngroup       Groups of users, used by getgrent(3) and related functions.\n\nhosts       Host names and numbers, used by gethostbyname(3) and related functions.\n\ninitgroups  Supplementary group access list, used by getgrouplist(3) function.\n\nnetgroup    Network-wide list of hosts and users, used for access rules.  C libraries  before\nglibc 2.1 supported netgroups only over NIS.\n\nnetworks    Network names and numbers, used by getnetent(3) and related functions.\n\npasswd      User passwords, used by getpwent(3) and related functions.\n\nprotocols   Network protocols, used by getprotoent(3) and related functions.\n\npublickey   Public and secret keys for SecureRPC used by NFS and NIS+.\n\nrpc         Remote  procedure  call  names  and  numbers, used by getrpcbyname(3) and related\nfunctions.\n\nservices    Network services, used by getservent(3) and related functions.\n\nshadow      Shadow user passwords, used by getspnam(3) and related functions.\n\nThe GNU C Library ignores databases with unknown names.  Some applications use this to imple‐\nment special handling for their own databases.  For example,  sudo(8)  consults  the  sudoers\ndatabase.   Delegation  of subordinate user/group IDs can be configured using the subid data‐\nbase.  Refer to subuid(5) and subgid(5) for more details.\n\nHere is an example /etc/nsswitch.conf file:\n\npasswd:         compat\ngroup:          compat\nshadow:         compat\n\nhosts:          dns [!UNAVAIL=return] files\nnetworks:       nis [NOTFOUND=return] files\nethers:         nis [NOTFOUND=return] files\nprotocols:      nis [NOTFOUND=return] files\nrpc:            nis [NOTFOUND=return] files\nservices:       nis [NOTFOUND=return] files\n\nThe first column is the database name.  The remaining columns specify:\n\n•  One or more service specifications, for example, \"files\", \"db\", or \"nis\".   The  order  of\nthe  services on the line determines the order in which those services will be queried, in\nturn, until a result is found.\n\n•  Optional actions to perform if a particular result is obtained from the preceding service,\nfor example, \"[NOTFOUND=return]\".\n\nThe service specifications supported on your system depend on  the  presence  of  shared  li‐\nbraries,  and  are therefore extensible.  Libraries called /lib/libnssSERVICE.so.X will pro‐\nvide the named SERVICE.  On a standard installation, you can use \"files\",  \"db\",  \"nis\",  and\n\"nisplus\".   For  the  hosts  database,  you can additionally specify \"dns\".  For the passwd,\ngroup, and shadow databases, you can additionally specify \"compat\"  (see  Compatibility  mode\nbelow).   The version number X may be 1 for glibc 2.0, or 2 for glibc 2.1 and later.  On sys‐\ntems with additional libraries installed, you may have access to  further  services  such  as\n\"hesiod\", \"ldap\", \"winbind\", and \"wins\".\n\nAn  action  may also be specified following a service specification.  The action modifies the\nbehavior following a result obtained from the preceding data source.  Action items  take  the\ngeneral form:\n\n[STATUS=ACTION]\n[!STATUS=ACTION]\n\nwhere\n\nSTATUS => success | notfound | unavail | tryagain\nACTION => return | continue | merge\n\nThe  ! negates the test, matching all possible results except the one specified.  The case of\nthe keywords is not significant.\n\nThe STATUS value is matched against the result of the lookup function called by the preceding\nservice specification, and can be one of:\n\nsuccess     No error occurred and the requested entry is returned.   The  default  action\nfor this condition is \"return\".\n\nnotfound    The lookup succeeded, but the requested entry was not found.  The default ac‐\ntion for this condition is \"continue\".\n\nunavail     The  service  is  permanently unavailable.  This can mean either that the re‐\nquired file cannot be read, or, for network services, that the server is  not\navailable  or  does not allow queries.  The default action for this condition\nis \"continue\".\n\ntryagain    The service is temporarily unavailable.  This could mean a file is locked  or\na  server  currently  cannot accept more connections.  The default action for\nthis condition is \"continue\".\n\nThe ACTION value can be one of:\n\nreturn      Return a result now.  Do not call any further lookup functions.  However, for\ncompatibility reasons, if this is the selected action for the group  database\nand  the  notfound  status,  and  the configuration file does not contain the\ninitgroups line, the next lookup function is always called, without affecting\nthe search result.\n\ncontinue    Call the next lookup function.\n\nmerge       [SUCCESS=merge] is used between two database entries.  When a  group  is  lo‐\ncated  in  the first of the two group entries, processing will continue on to\nthe next one.  If the group is also found in the next entry  (and  the  group\nname and GID are an exact match), the member list of the second entry will be\nadded  to the group object to be returned.  Available since glibc 2.24.  Note\nthat merging will not be done for getgrent(3) nor will duplicate  members  be\npruned when they occur in both entries being merged.\n",
            "subsections": [
                {
                    "name": "Compatibility mode (compat)",
                    "content": "The  NSS  \"compat\"  service is similar to \"files\" except that it additionally permits special\nentries in corresponding files for granting users or members of netgroups access to the  sys‐\ntem.  The following entries are valid in this mode:\n\nFor passwd and shadow databases:\n\n+user       Include the specified user from the NIS passwd/shadow map.\n\n+user:::::: Include  the  specified  user  from the NIS passwd map, but override with\nnon-empty passwd fields.\n\n+@netgroup  Include all users in the given netgroup.\n\n-user       Exclude the specified user from the NIS passwd/shadow map.\n\n-@netgroup  Exclude all users in the given netgroup.\n\n+           Include every  user,  except  previously  excluded  ones,  from  the  NIS\npasswd/shadow map.\n\nFor group database:\n\n+group      Include the specified group from the NIS group map.\n\n-group      Exclude the specified group from the NIS group map.\n\n+           Include  every group, except previously excluded ones, from the NIS group\nmap.\n\nBy default, the source is \"nis\", but this may be overridden by specifying any NSS service ex‐\ncept \"compat\" itself as the source for the pseudo-databases passwdcompat, groupcompat,  and\nshadowcompat.\n"
                }
            ]
        },
        "FILES": {
            "content": "A  service  named SERVICE is implemented by a shared object library named libnssSERVICE.so.X\nthat resides in /lib.\n\n/etc/nsswitch.conf       NSS configuration file.\n/lib/libnsscompat.so.X  implements \"compat\" source.\n/lib/libnssdb.so.X      implements \"db\" source.\n/lib/libnssdns.so.X     implements \"dns\" source.\n/lib/libnssfiles.so.X   implements \"files\" source.\n/lib/libnsshesiod.so.X  implements \"hesiod\" source.\n/lib/libnssnis.so.X     implements \"nis\" source.\n/lib/libnssnisplus.so.X implements \"nisplus\" source.\n\nThe following files are read when \"files\" source is specified for respective databases:\n\naliases     /etc/aliases\nethers      /etc/ethers\ngroup       /etc/group\nhosts       /etc/hosts\ninitgroups  /etc/group\nnetgroup    /etc/netgroup\nnetworks    /etc/networks\npasswd      /etc/passwd\nprotocols   /etc/protocols\npublickey   /etc/publickey\nrpc         /etc/rpc\nservices    /etc/services\nshadow      /etc/shadow\n",
            "subsections": []
        },
        "NOTES": {
            "content": "Starting with glibc 2.33, nsswitch.conf is automatically reloaded if the file is changed.  In\nearlier versions, the entire file was read only once within each process.  If  the  file  was\nlater changed, the process would continue using the old configuration.\n\nTraditionally, there was only a single source for service information, often in the form of a\nsingle  configuration file (e.g., /etc/passwd).  However, as other name services, such as the\nNetwork Information Service (NIS) and the Domain Name Service (DNS), became popular, a method\nwas needed that would be more flexible than fixed search orders coded  into  the  C  library.\nThe  Name Service Switch mechanism, which was based on the mechanism used by Sun Microsystems\nin the Solaris 2 C library, introduced a cleaner solution to the problem.\n",
            "subsections": []
        },
        "SEE ALSO": {
            "content": "getent(1), nss(5)\n\nLinux man-pages 6.7                          2023-10-31                             nsswitch.conf(5)",
            "subsections": []
        }
    },
    "summary": "nsswitch.conf - Name Service Switch configuration file",
    "flags": [],
    "examples": [],
    "see_also": [
        {
            "name": "getent",
            "section": "1",
            "url": "https://www.chedong.com/phpMan.php/man/getent/1/json"
        },
        {
            "name": "nss",
            "section": "5",
            "url": "https://www.chedong.com/phpMan.php/man/nss/5/json"
        }
    ]
}