]> git.ipfire.org Git - thirdparty/man-pages.git/blob - man1/getent.1
localedef.1, close.2, copy_file_range.2, execve.2, get_robust_list.2, getdomainname...
[thirdparty/man-pages.git] / man1 / getent.1
1 .\" Copyright (c) 2011, Mark R. Bannister <cambridge@users.sourceforge.net>
2 .\" Copyright (c) 2015, Robin H. Johnson <robbat2@gentoo.org>
3 .\"
4 .\" %%%LICENSE_START(GPLv2+_DOC_FULL)
5 .\" This is free documentation; you can redistribute it and/or
6 .\" modify it under the terms of the GNU General Public License as
7 .\" published by the Free Software Foundation; either version 2 of
8 .\" the License, or (at your option) any later version.
9 .\"
10 .\" The GNU General Public License's references to "object code"
11 .\" and "executables" are to be interpreted as the output of any
12 .\" document formatting or typesetting system, including
13 .\" intermediate and printed output.
14 .\"
15 .\" This manual is distributed in the hope that it will be useful,
16 .\" but WITHOUT ANY WARRANTY; without even the implied warranty of
17 .\" MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
18 .\" GNU General Public License for more details.
19 .\"
20 .\" You should have received a copy of the GNU General Public
21 .\" License along with this manual; if not, see
22 .\" <http://www.gnu.org/licenses/>.
23 .\" %%%LICENSE_END
24 .\"
25 .TH GETENT 1 2019-03-06 "Linux" "User Commands"
26 .SH NAME
27 getent \- get entries from Name Service Switch libraries
28 .SH SYNOPSIS
29 .B getent\ [\fIoption\fP]...\ \fIdatabase\fP\ \fIkey\fP...
30 .SH DESCRIPTION
31 The
32 .B getent
33 command displays entries from databases supported by the
34 Name Service Switch libraries,
35 which are configured in
36 .IR /etc/nsswitch.conf .
37 If one or more
38 .I key
39 arguments are provided,
40 then only the entries that match the supplied keys will be displayed.
41 Otherwise, if no
42 .I key
43 is provided, all entries will be displayed (unless the database does not
44 support enumeration).
45 .PP
46 The
47 .I database
48 may be any of those supported by the GNU C Library, listed below:
49 .RS 3
50 .TP 10
51 .B ahosts
52 When no
53 .I key
54 is provided, use
55 .BR sethostent (3),
56 .BR gethostent (3),
57 and
58 .BR endhostent (3)
59 to enumerate the hosts database.
60 This is identical to using
61 .BR hosts .
62 When one or more
63 .I key
64 arguments are provided, pass each
65 .I key
66 in succession to
67 .BR getaddrinfo (3)
68 with the address family
69 .BR AF_UNSPEC ,
70 enumerating each socket address structure returned.
71 .TP
72 .B ahostsv4
73 Same as
74 .BR ahosts ,
75 but use the address family
76 .BR AF_INET .
77 .TP
78 .B ahostsv6
79 Same as
80 .BR ahosts ,
81 but use the address family
82 .BR AF_INET6 .
83 The call to
84 .BR getaddrinfo (3)
85 in this case includes the
86 .B AI_V4MAPPED
87 flag.
88 .TP
89 .B aliases
90 When no
91 .I key
92 is provided, use
93 .BR setaliasent (3),
94 .BR getaliasent (3),
95 and
96 .BR endaliasent (3)
97 to enumerate the aliases database.
98 When one or more
99 .I key
100 arguments are provided, pass each
101 .I key
102 in succession to
103 .BR getaliasbyname (3)
104 and display the result.
105 .TP
106 .B ethers
107 When one or more
108 .I key
109 arguments are provided, pass each
110 .I key
111 in succession to
112 .BR ether_aton (3)
113 and
114 .BR ether_hostton (3)
115 until a result is obtained, and display the result.
116 Enumeration is not supported on
117 .BR ethers ,
118 so a
119 .I key
120 must be provided.
121 .TP
122 .B group
123 When no
124 .I key
125 is provided, use
126 .BR setgrent (3),
127 .BR getgrent (3),
128 and
129 .BR endgrent (3)
130 to enumerate the group database.
131 When one or more
132 .I key
133 arguments are provided, pass each numeric
134 .I key
135 to
136 .BR getgrgid (3)
137 and each nonnumeric
138 .I key
139 to
140 .BR getgrnam (3)
141 and display the result.
142 .TP
143 .B gshadow
144 When no
145 .I key
146 is provided, use
147 .BR setsgent (3),
148 .BR getsgent (3),
149 and
150 .BR endsgent (3)
151 to enumerate the gshadow database.
152 When one or more
153 .I key
154 arguments are provided, pass each
155 .I key
156 in succession to
157 .BR getsgnam (3)
158 and display the result.
159 .TP
160 .B hosts
161 When no
162 .I key
163 is provided, use
164 .BR sethostent (3),
165 .BR gethostent (3),
166 and
167 .BR endhostent (3)
168 to enumerate the hosts database.
169 When one or more
170 .I key
171 arguments are provided, pass each
172 .I key
173 to
174 .BR gethostbyaddr (3)
175 or
176 .BR gethostbyname2 (3),
177 depending on whether a call to
178 .BR inet_pton (3)
179 indicates that the
180 .I key
181 is an IPv6 or IPv4 address or not, and display the result.
182 .TP
183 .B initgroups
184 When one or more
185 .I key
186 arguments are provided, pass each
187 .I key
188 in succession to
189 .BR getgrouplist (3)
190 and display the result.
191 Enumeration is not supported on
192 .BR initgroups ,
193 so a
194 .I key
195 must be provided.
196 .TP
197 .B netgroup
198 When one
199 .I key
200 is provided, pass the
201 .I key
202 to
203 .BR setnetgrent (3)
204 and, using
205 .BR getnetgrent (3)
206 display the resulting string triple
207 .RI ( hostname ", " username ", " domainname ).
208 Alternatively, three
209 .I keys
210 may be provided, which are interpreted as the
211 .IR hostname ,
212 .I username
213 and
214 .I domainname
215 to match to a netgroup name via
216 .BR innetgr (3).
217 Enumeration is not supported on
218 .BR netgroup ,
219 so either one or three
220 .I keys
221 must be provided.
222 .TP
223 .B networks
224 When no
225 .I key
226 is provided, use
227 .BR setnetent (3),
228 .BR getnetent (3),
229 and
230 .BR endnetent (3)
231 to enumerate the networks database.
232 When one or more
233 .I key
234 arguments are provided, pass each numeric
235 .I key
236 to
237 .BR getnetbyaddr (3)
238 and each nonnumeric
239 .I key
240 to
241 .BR getnetbyname (3)
242 and display the result.
243 .TP
244 .B passwd
245 When no
246 .I key
247 is provided, use
248 .BR setpwent (3),
249 .BR getpwent (3),
250 and
251 .BR endpwent (3)
252 to enumerate the passwd database.
253 When one or more
254 .I key
255 arguments are provided, pass each numeric
256 .I key
257 to
258 .BR getpwuid (3)
259 and each nonnumeric
260 .I key
261 to
262 .BR getpwnam (3)
263 and display the result.
264 .TP
265 .B protocols
266 When no
267 .I key
268 is provided, use
269 .BR setprotoent (3),
270 .BR getprotoent (3),
271 and
272 .BR endprotoent (3)
273 to enumerate the protocols database.
274 When one or more
275 .I key
276 arguments are provided, pass each numeric
277 .I key
278 to
279 .BR getprotobynumber (3)
280 and each nonnumeric
281 .I key
282 to
283 .BR getprotobyname (3)
284 and display the result.
285 .TP
286 .B rpc
287 When no
288 .I key
289 is provided, use
290 .BR setrpcent (3),
291 .BR getrpcent (3),
292 and
293 .BR endrpcent (3)
294 to enumerate the rpc database.
295 When one or more
296 .I key
297 arguments are provided, pass each numeric
298 .I key
299 to
300 .BR getrpcbynumber (3)
301 and each nonnumeric
302 .I key
303 to
304 .BR getrpcbyname (3)
305 and display the result.
306 .TP
307 .B services
308 When no
309 .I key
310 is provided, use
311 .BR setservent (3),
312 .BR getservent (3),
313 and
314 .BR endservent (3)
315 to enumerate the services database.
316 When one or more
317 .I key
318 arguments are provided, pass each numeric
319 .I key
320 to
321 .BR getservbynumber (3)
322 and each nonnumeric
323 .I key
324 to
325 .BR getservbyname (3)
326 and display the result.
327 .TP
328 .B shadow
329 When no
330 .I key
331 is provided, use
332 .BR setspent (3),
333 .BR getspent (3),
334 and
335 .BR endspent (3)
336 to enumerate the shadow database.
337 When one or more
338 .I key
339 arguments are provided, pass each
340 .I key
341 in succession to
342 .BR getspnam (3)
343 and display the result.
344 .RE
345 .SH OPTIONS
346 .TP
347 .BR \-s\ \fIservice\fP ", " \-\-service\ \fIservice\fP
348 .\" commit 9d0881aa76b399e6a025c5cf44bebe2ae0efa8af (glibc)
349 Override all databases with the specified service.
350 (Since glibc 2.2.5.)
351 .TP
352 .BR \-s\ \fIdatabase\fP:\fIservice\fP ", "\
353 \-\-service\ \fIdatabase\fP:\fIservice\fP
354 .\" commit b4f6f4be85d32b9c03361c38376e36f08100e3e8 (glibc)
355 Override only specified databases with the specified service.
356 The option may be used multiple times,
357 but only the last service for each database will be used.
358 (Since glibc 2.4.)
359 .TP
360 .BR \-i ", " \-\-no\-idn
361 .\" commit a160f8d808cf8020b13bd0ef4a9eaf3c11f964ad (glibc)
362 Disables IDN encoding in lookups for
363 .BR ahosts / getaddrinfo (3)
364 (Since glibc-2.13.)
365 .TP
366 .BR \-? ", " \-\-help
367 Print a usage summary and exit.
368 .TP
369 .B "\-\-usage"
370 Print a short usage summary and exit.
371 .TP
372 .BR \-V ", " \-\-version
373 Print the version number, license, and disclaimer of warranty for
374 .BR getent .
375 .SH EXIT STATUS
376 One of the following exit values can be returned by
377 .BR getent :
378 .RS 3
379 .TP 10
380 .B 0
381 Command completed successfully.
382 .TP
383 .B 1
384 Missing arguments, or
385 .I database
386 unknown.
387 .TP
388 .B 2
389 One or more supplied
390 .I key
391 could not be found in the
392 .IR database .
393 .TP
394 .B 3
395 Enumeration not supported on this
396 .IR database .
397 .RE
398 .SH SEE ALSO
399 .BR nsswitch.conf (5)