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