Debian Codegraph @

upstream/debian-unstable/man1/getent.1

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