]>
Commit | Line | Data |
---|---|---|
4a009a37 | 1 | .\" Copyright (c) 2011, Mark R. Bannister <cambridge@users.sourceforge.net> |
ba0315b7 | 2 | .\" Copyright (c) 2015, Robin H. Johnson <robbat2@gentoo.org> |
4a009a37 | 3 | .\" |
1dd72f9c | 4 | .\" %%%LICENSE_START(GPLv2+_DOC_FULL) |
4a009a37 MB |
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 | |
c715f741 MK |
21 | .\" License along with this manual; if not, see |
22 | .\" <http://www.gnu.org/licenses/>. | |
6a8d8745 | 23 | .\" %%%LICENSE_END |
4a009a37 | 24 | .\" |
e8426ca2 | 25 | .TH GETENT 1 2020-04-11 "Linux" "User Commands" |
4a009a37 MB |
26 | .SH NAME |
27 | getent \- get entries from Name Service Switch libraries | |
28 | .SH SYNOPSIS | |
a28b73cd | 29 | .B getent\ [\fIoption\fP]...\ \fIdatabase\fP\ \fIkey\fP... |
4a009a37 | 30 | .SH DESCRIPTION |
3fd39ec4 | 31 | The |
a9aa137a | 32 | .B getent |
3fd39ec4 MK |
33 | command displays entries from databases supported by the |
34 | Name Service Switch libraries, | |
4a009a37 MB |
35 | which are configured in |
36 | .IR /etc/nsswitch.conf . | |
37 | If one or more | |
38 | .I key | |
3fd39ec4 MK |
39 | arguments are provided, |
40 | then only the entries that match the supplied keys will be displayed. | |
4a009a37 MB |
41 | Otherwise, if no |
42 | .I key | |
43 | is provided, all entries will be displayed (unless the database does not | |
44 | support enumeration). | |
dd3568a1 | 45 | .PP |
4a009a37 MB |
46 | The |
47 | .I database | |
3fd39ec4 | 48 | may be any of those supported by the GNU C Library, listed below: |
4a009a37 MB |
49 | .RS 3 |
50 | .TP 10 | |
51 | .B ahosts | |
52 | When no | |
53 | .I key | |
3fd39ec4 | 54 | is provided, use |
4a009a37 | 55 | .BR sethostent (3), |
3fd39ec4 | 56 | .BR gethostent (3), |
4a009a37 MB |
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 | |
3fd39ec4 | 64 | arguments are provided, pass each |
4a009a37 MB |
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 | |
3fd39ec4 MK |
74 | .BR ahosts , |
75 | but use the address family | |
4a009a37 MB |
76 | .BR AF_INET . |
77 | .TP | |
78 | .B ahostsv6 | |
79 | Same as | |
3fd39ec4 MK |
80 | .BR ahosts , |
81 | but use the address family | |
4a009a37 MB |
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 | |
3fd39ec4 | 92 | is provided, use |
4a009a37 | 93 | .BR setaliasent (3), |
3fd39ec4 | 94 | .BR getaliasent (3), |
4a009a37 MB |
95 | and |
96 | .BR endaliasent (3) | |
97 | to enumerate the aliases database. | |
98 | When one or more | |
99 | .I key | |
3fd39ec4 | 100 | arguments are provided, pass each |
4a009a37 MB |
101 | .I key |
102 | in succession to | |
103 | .BR getaliasbyname (3) | |
3fd39ec4 | 104 | and display the result. |
4a009a37 MB |
105 | .TP |
106 | .B ethers | |
107 | When one or more | |
108 | .I key | |
3fd39ec4 | 109 | arguments are provided, pass each |
4a009a37 MB |
110 | .I key |
111 | in succession to | |
112 | .BR ether_aton (3) | |
113 | and | |
114 | .BR ether_hostton (3) | |
3fd39ec4 | 115 | until a result is obtained, and display the result. |
4a009a37 MB |
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 | |
3fd39ec4 | 125 | is provided, use |
4a009a37 | 126 | .BR setgrent (3), |
3fd39ec4 | 127 | .BR getgrent (3), |
4a009a37 MB |
128 | and |
129 | .BR endgrent (3) | |
130 | to enumerate the group database. | |
131 | When one or more | |
132 | .I key | |
3fd39ec4 | 133 | arguments are provided, pass each numeric |
4a009a37 MB |
134 | .I key |
135 | to | |
136 | .BR getgrgid (3) | |
3fd39ec4 | 137 | and each nonnumeric |
4a009a37 MB |
138 | .I key |
139 | to | |
140 | .BR getgrnam (3) | |
3fd39ec4 | 141 | and display the result. |
4a009a37 MB |
142 | .TP |
143 | .B gshadow | |
144 | When no | |
145 | .I key | |
3fd39ec4 | 146 | is provided, use |
4a009a37 | 147 | .BR setsgent (3), |
3fd39ec4 | 148 | .BR getsgent (3), |
4a009a37 MB |
149 | and |
150 | .BR endsgent (3) | |
151 | to enumerate the gshadow database. | |
152 | When one or more | |
153 | .I key | |
3fd39ec4 | 154 | arguments are provided, pass each |
4a009a37 MB |
155 | .I key |
156 | in succession to | |
157 | .BR getsgnam (3) | |
3fd39ec4 | 158 | and display the result. |
4a009a37 MB |
159 | .TP |
160 | .B hosts | |
161 | When no | |
162 | .I key | |
3fd39ec4 | 163 | is provided, use |
4a009a37 | 164 | .BR sethostent (3), |
3fd39ec4 | 165 | .BR gethostent (3), |
4a009a37 MB |
166 | and |
167 | .BR endhostent (3) | |
168 | to enumerate the hosts database. | |
169 | When one or more | |
170 | .I key | |
3fd39ec4 | 171 | arguments are provided, pass each |
4a009a37 MB |
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 | |
3fd39ec4 | 181 | is an IPv6 or IPv4 address or not, and display the result. |
4a009a37 MB |
182 | .TP |
183 | .B initgroups | |
184 | When one or more | |
185 | .I key | |
3fd39ec4 | 186 | arguments are provided, pass each |
4a009a37 MB |
187 | .I key |
188 | in succession to | |
189 | .BR getgrouplist (3) | |
3fd39ec4 | 190 | and display the result. |
4a009a37 MB |
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 | |
3fd39ec4 | 200 | is provided, pass the |
4a009a37 MB |
201 | .I key |
202 | to | |
203 | .BR setnetgrent (3) | |
204 | and, using | |
205 | .BR getnetgrent (3) | |
3fd39ec4 | 206 | display the resulting string triple |
4a009a37 MB |
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 | |
06ba9031 | 218 | .BR netgroup , |
4a009a37 MB |
219 | so either one or three |
220 | .I keys | |
221 | must be provided. | |
222 | .TP | |
223 | .B networks | |
224 | When no | |
225 | .I key | |
3fd39ec4 | 226 | is provided, use |
4a009a37 | 227 | .BR setnetent (3), |
3fd39ec4 | 228 | .BR getnetent (3), |
4a009a37 MB |
229 | and |
230 | .BR endnetent (3) | |
231 | to enumerate the networks database. | |
232 | When one or more | |
233 | .I key | |
3fd39ec4 | 234 | arguments are provided, pass each numeric |
4a009a37 MB |
235 | .I key |
236 | to | |
237 | .BR getnetbyaddr (3) | |
3fd39ec4 | 238 | and each nonnumeric |
4a009a37 MB |
239 | .I key |
240 | to | |
241 | .BR getnetbyname (3) | |
3fd39ec4 | 242 | and display the result. |
4a009a37 MB |
243 | .TP |
244 | .B passwd | |
245 | When no | |
246 | .I key | |
3fd39ec4 | 247 | is provided, use |
4a009a37 | 248 | .BR setpwent (3), |
3fd39ec4 | 249 | .BR getpwent (3), |
4a009a37 MB |
250 | and |
251 | .BR endpwent (3) | |
252 | to enumerate the passwd database. | |
253 | When one or more | |
254 | .I key | |
3fd39ec4 | 255 | arguments are provided, pass each numeric |
4a009a37 MB |
256 | .I key |
257 | to | |
258 | .BR getpwuid (3) | |
3fd39ec4 | 259 | and each nonnumeric |
4a009a37 MB |
260 | .I key |
261 | to | |
262 | .BR getpwnam (3) | |
3fd39ec4 | 263 | and display the result. |
4a009a37 MB |
264 | .TP |
265 | .B protocols | |
266 | When no | |
267 | .I key | |
3fd39ec4 | 268 | is provided, use |
4a009a37 | 269 | .BR setprotoent (3), |
3fd39ec4 | 270 | .BR getprotoent (3), |
4a009a37 MB |
271 | and |
272 | .BR endprotoent (3) | |
273 | to enumerate the protocols database. | |
274 | When one or more | |
275 | .I key | |
3fd39ec4 | 276 | arguments are provided, pass each numeric |
4a009a37 MB |
277 | .I key |
278 | to | |
279 | .BR getprotobynumber (3) | |
3fd39ec4 | 280 | and each nonnumeric |
4a009a37 MB |
281 | .I key |
282 | to | |
283 | .BR getprotobyname (3) | |
3fd39ec4 | 284 | and display the result. |
4a009a37 MB |
285 | .TP |
286 | .B rpc | |
287 | When no | |
288 | .I key | |
3fd39ec4 | 289 | is provided, use |
4a009a37 | 290 | .BR setrpcent (3), |
3fd39ec4 | 291 | .BR getrpcent (3), |
4a009a37 MB |
292 | and |
293 | .BR endrpcent (3) | |
294 | to enumerate the rpc database. | |
295 | When one or more | |
296 | .I key | |
3fd39ec4 | 297 | arguments are provided, pass each numeric |
4a009a37 MB |
298 | .I key |
299 | to | |
300 | .BR getrpcbynumber (3) | |
3fd39ec4 | 301 | and each nonnumeric |
4a009a37 MB |
302 | .I key |
303 | to | |
304 | .BR getrpcbyname (3) | |
3fd39ec4 | 305 | and display the result. |
4a009a37 MB |
306 | .TP |
307 | .B services | |
308 | When no | |
309 | .I key | |
3fd39ec4 | 310 | is provided, use |
4a009a37 | 311 | .BR setservent (3), |
3fd39ec4 | 312 | .BR getservent (3), |
4a009a37 MB |
313 | and |
314 | .BR endservent (3) | |
315 | to enumerate the services database. | |
316 | When one or more | |
317 | .I key | |
3fd39ec4 | 318 | arguments are provided, pass each numeric |
4a009a37 MB |
319 | .I key |
320 | to | |
321 | .BR getservbynumber (3) | |
3fd39ec4 | 322 | and each nonnumeric |
4a009a37 MB |
323 | .I key |
324 | to | |
325 | .BR getservbyname (3) | |
3fd39ec4 | 326 | and display the result. |
4a009a37 MB |
327 | .TP |
328 | .B shadow | |
329 | When no | |
330 | .I key | |
3fd39ec4 | 331 | is provided, use |
4a009a37 | 332 | .BR setspent (3), |
3fd39ec4 | 333 | .BR getspent (3), |
4a009a37 MB |
334 | and |
335 | .BR endspent (3) | |
336 | to enumerate the shadow database. | |
337 | When one or more | |
338 | .I key | |
3fd39ec4 | 339 | arguments are provided, pass each |
4a009a37 MB |
340 | .I key |
341 | in succession to | |
342 | .BR getspnam (3) | |
3fd39ec4 | 343 | and display the result. |
4a009a37 | 344 | .RE |
ba0315b7 RJ |
345 | .SH OPTIONS |
346 | .TP | |
0d28496a | 347 | .BR \-s\ \fIservice\fP ", " \-\-service\ \fIservice\fP |
ba0315b7 | 348 | .\" commit 9d0881aa76b399e6a025c5cf44bebe2ae0efa8af (glibc) |
448dc232 MK |
349 | Override all databases with the specified service. |
350 | (Since glibc 2.2.5.) | |
ba0315b7 | 351 | .TP |
0d28496a | 352 | .BR \-s\ \fIdatabase\fP:\fIservice\fP ", "\ |
448dc232 | 353 | \-\-service\ \fIdatabase\fP:\fIservice\fP |
ba0315b7 | 354 | .\" commit b4f6f4be85d32b9c03361c38376e36f08100e3e8 (glibc) |
448dc232 MK |
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.) | |
ba0315b7 | 359 | .TP |
448dc232 | 360 | .BR \-i ", " \-\-no\-idn |
ba0315b7 RJ |
361 | .\" commit a160f8d808cf8020b13bd0ef4a9eaf3c11f964ad (glibc) |
362 | Disables IDN encoding in lookups for | |
448dc232 | 363 | .BR ahosts / getaddrinfo (3) |
ba0315b7 | 364 | (Since glibc-2.13.) |
d4c47e46 MK |
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 . | |
47297adb | 375 | .SH EXIT STATUS |
4a009a37 MB |
376 | One of the following exit values can be returned by |
377 | .BR getent : | |
378 | .RS 3 | |
0019177e | 379 | .TP |
4a009a37 MB |
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 | |
47297adb | 398 | .SH SEE ALSO |
3fd39ec4 | 399 | .BR nsswitch.conf (5) |