1nsswitch.conf(5) File Formats Manual nsswitch.conf(5)
2
3
4
6 nsswitch.conf - Name Service Switch configuration file
7
9 The Name Service Switch (NSS) configuration file, /etc/nsswitch.conf,
10 is used by the GNU C Library and certain other applications to deter‐
11 mine the sources from which to obtain name-service information in a
12 range of categories, and in what order. Each category of information
13 is identified by a database name.
14
15 The file is plain ASCII text, with columns separated by spaces or tab
16 characters. The first column specifies the database name. The remain‐
17 ing columns describe the order of sources to query and a limited set of
18 actions that can be performed by lookup result.
19
20 The following databases are understood by the GNU C Library:
21
22 aliases Mail aliases, used by getaliasent(3) and related functions.
23
24 ethers Ethernet numbers.
25
26 group Groups of users, used by getgrent(3) and related functions.
27
28 hosts Host names and numbers, used by gethostbyname(3) and re‐
29 lated functions.
30
31 initgroups Supplementary group access list, used by getgrouplist(3)
32 function.
33
34 netgroup Network-wide list of hosts and users, used for access
35 rules. C libraries before glibc 2.1 supported netgroups
36 only over NIS.
37
38 networks Network names and numbers, used by getnetent(3) and related
39 functions.
40
41 passwd User passwords, used by getpwent(3) and related functions.
42
43 protocols Network protocols, used by getprotoent(3) and related func‐
44 tions.
45
46 publickey Public and secret keys for Secure_RPC used by NFS and NIS+.
47
48 rpc Remote procedure call names and numbers, used by getrpcby‐
49 name(3) and related functions.
50
51 services Network services, used by getservent(3) and related func‐
52 tions.
53
54 shadow Shadow user passwords, used by getspnam(3) and related
55 functions.
56
57 The GNU C Library ignores databases with unknown names. Some applica‐
58 tions use this to implement special handling for their own databases.
59 For example, sudo(8) consults the sudoers database. Delegation of sub‐
60 ordinate user/group IDs can be configured using the subid database.
61 Refer to subuid(5) and subgid(5) for more details.
62
63 Here is an example /etc/nsswitch.conf file:
64
65 passwd: compat
66 group: compat
67 shadow: compat
68
69 hosts: dns [!UNAVAIL=return] files
70 networks: nis [NOTFOUND=return] files
71 ethers: nis [NOTFOUND=return] files
72 protocols: nis [NOTFOUND=return] files
73 rpc: nis [NOTFOUND=return] files
74 services: nis [NOTFOUND=return] files
75
76 The first column is the database name. The remaining columns specify:
77
78 • One or more service specifications, for example, "files", "db", or
79 "nis". The order of the services on the line determines the order
80 in which those services will be queried, in turn, until a result is
81 found.
82
83 • Optional actions to perform if a particular result is obtained from
84 the preceding service, for example, "[NOTFOUND=return]".
85
86 The service specifications supported on your system depend on the pres‐
87 ence of shared libraries, and are therefore extensible. Libraries
88 called /lib/libnss_SERVICE.so.X will provide the named SERVICE. On a
89 standard installation, you can use "files", "db", "nis", and "nisplus".
90 For the hosts database, you can additionally specify "dns". For the
91 passwd, group, and shadow databases, you can additionally specify "com‐
92 pat" (see Compatibility mode below). The version number X may be 1 for
93 glibc 2.0, or 2 for glibc 2.1 and later. On systems with additional
94 libraries installed, you may have access to further services such as
95 "hesiod", "ldap", "winbind", and "wins".
96
97 An action may also be specified following a service specification. The
98 action modifies the behavior following a result obtained from the pre‐
99 ceding data source. Action items take the general form:
100
101 [STATUS=ACTION]
102 [!STATUS=ACTION]
103
104 where
105
106 STATUS => success | notfound | unavail | tryagain
107 ACTION => return | continue | merge
108
109 The ! negates the test, matching all possible results except the one
110 specified. The case of the keywords is not significant.
111
112 The STATUS value is matched against the result of the lookup function
113 called by the preceding service specification, and can be one of:
114
115 success No error occurred and the requested entry is returned.
116 The default action for this condition is "return".
117
118 notfound The lookup succeeded, but the requested entry was not
119 found. The default action for this condition is "con‐
120 tinue".
121
122 unavail The service is permanently unavailable. This can mean
123 either that the required file cannot be read, or, for
124 network services, that the server is not available or
125 does not allow queries. The default action for this
126 condition is "continue".
127
128 tryagain The service is temporarily unavailable. This could
129 mean a file is locked or a server currently cannot ac‐
130 cept more connections. The default action for this
131 condition is "continue".
132
133 The ACTION value can be one of:
134
135 return Return a result now. Do not call any further lookup
136 functions. However, for compatibility reasons, if this
137 is the selected action for the group database and the
138 notfound status, and the configuration file does not
139 contain the initgroups line, the next lookup function
140 is always called, without affecting the search result.
141
142 continue Call the next lookup function.
143
144 merge [SUCCESS=merge] is used between two database entries.
145 When a group is located in the first of the two group
146 entries, processing will continue on to the next one.
147 If the group is also found in the next entry (and the
148 group name and GID are an exact match), the member list
149 of the second entry will be added to the group object
150 to be returned. Available since glibc 2.24. Note that
151 merging will not be done for getgrent(3) nor will du‐
152 plicate members be pruned when they occur in both en‐
153 tries being merged.
154
155 Compatibility mode (compat)
156 The NSS "compat" service is similar to "files" except that it addition‐
157 ally permits special entries in corresponding files for granting users
158 or members of netgroups access to the system. The following entries
159 are valid in this mode:
160
161 For passwd and shadow databases:
162
163 +user Include the specified user from the NIS
164 passwd/shadow map.
165
166 +@netgroup Include all users in the given netgroup.
167
168 -user Exclude the specified user from the NIS
169 passwd/shadow map.
170
171 -@netgroup Exclude all users in the given netgroup.
172
173 + Include every user, except previously excluded
174 ones, from the NIS passwd/shadow map.
175
176 For group database:
177
178 +group Include the specified group from the NIS group map.
179
180 -group Exclude the specified group from the NIS group map.
181
182 + Include every group, except previously excluded
183 ones, from the NIS group map.
184
185 By default, the source is "nis", but this may be overridden by specify‐
186 ing any NSS service except "compat" itself as the source for the
187 pseudo-databases passwd_compat, group_compat, and shadow_compat.
188
190 A service named SERVICE is implemented by a shared object library named
191 libnss_SERVICE.so.X that resides in /lib.
192
193 /etc/nsswitch.conf NSS configuration file.
194 /lib/libnss_compat.so.X implements "compat" source.
195 /lib/libnss_db.so.X implements "db" source.
196 /lib/libnss_dns.so.X implements "dns" source.
197 /lib/libnss_files.so.X implements "files" source.
198 /lib/libnss_hesiod.so.X implements "hesiod" source.
199 /lib/libnss_nis.so.X implements "nis" source.
200 /lib/libnss_nisplus.so.X implements "nisplus" source.
201
202 The following files are read when "files" source is specified for re‐
203 spective databases:
204
205 aliases /etc/aliases
206 ethers /etc/ethers
207 group /etc/group
208 hosts /etc/hosts
209 initgroups /etc/group
210 netgroup /etc/netgroup
211 networks /etc/networks
212 passwd /etc/passwd
213 protocols /etc/protocols
214 publickey /etc/publickey
215 rpc /etc/rpc
216 services /etc/services
217 shadow /etc/shadow
218
220 Starting with glibc 2.33, nsswitch.conf is automatically reloaded if
221 the file is changed. In earlier versions, the entire file was read
222 only once within each process. If the file was later changed, the
223 process would continue using the old configuration.
224
225 Traditionally, there was only a single source for service information,
226 often in the form of a single configuration file (e.g., /etc/passwd).
227 However, as other name services, such as the Network Information Ser‐
228 vice (NIS) and the Domain Name Service (DNS), became popular, a method
229 was needed that would be more flexible than fixed search orders coded
230 into the C library. The Name Service Switch mechanism, which was based
231 on the mechanism used by Sun Microsystems in the Solaris 2 C library,
232 introduced a cleaner solution to the problem.
233
235 getent(1), nss(5)
236
237
238
239Linux man-pages 6.04 2023-02-05 nsswitch.conf(5)