Debian Codegraph @

upstream/debian-trixie/man1/getent.1

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