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