OSDN Git Service

7b1c46cddb9112477f79be3ff8b2abab00678ff1
[linuxjm/LDP_man-pages.git] / original / man1 / getent.1
1 .\" Copyright (c) 2011, Mark R. Bannister <cambridge@users.sourceforge.net>
2 .\"
3 .\" %%%LICENSE_START(GPLv2+_DOC_FULL)
4 .\" This is free documentation; you can redistribute it and/or
5 .\" modify it under the terms of the GNU General Public License as
6 .\" published by the Free Software Foundation; either version 2 of
7 .\" the License, or (at your option) any later version.
8 .\"
9 .\" The GNU General Public License's references to "object code"
10 .\" and "executables" are to be interpreted as the output of any
11 .\" document formatting or typesetting system, including
12 .\" intermediate and printed output.
13 .\"
14 .\" This manual is distributed in the hope that it will be useful,
15 .\" but WITHOUT ANY WARRANTY; without even the implied warranty of
16 .\" MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
17 .\" GNU General Public License for more details.
18 .\"
19 .\" You should have received a copy of the GNU General Public
20 .\" License along with this manual; if not, see
21 .\" <http://www.gnu.org/licenses/>.
22 .\" %%%LICENSE_END
23 .\"
24 .TH GETENT 1 2013-03-15 "Linux" "User Commands"
25 .SH NAME
26 getent \- get entries from Name Service Switch libraries
27 .SH SYNOPSIS
28 .B "getent
29 .IR database " [" key " ...]"
30 .SH DESCRIPTION
31 The
32 .B getent
33 command displays entries from databases supported by the
34 Name Service Switch libraries,
35 which are configured in
36 .IR /etc/nsswitch.conf .
37 If one or more
38 .I key
39 arguments are provided,
40 then only the entries that match the supplied keys will be displayed.
41 Otherwise, if no
42 .I key
43 is provided, all entries will be displayed (unless the database does not
44 support enumeration).
45 .LP
46 The
47 .I database
48 may be any of those supported by the GNU C Library, listed below:
49 .RS 3
50 .TP 10
51 .B ahosts
52 When no
53 .I key
54 is provided, use
55 .BR sethostent (3),
56 .BR gethostent (3),
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
64 arguments are provided, pass each
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
74 .BR ahosts ,
75 but use the address family
76 .BR AF_INET .
77 .TP
78 .B ahostsv6
79 Same as
80 .BR ahosts ,
81 but use the address family
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
92 is provided, use
93 .BR setaliasent (3),
94 .BR getaliasent (3),
95 and
96 .BR endaliasent (3)
97 to enumerate the aliases database.
98 When one or more
99 .I key
100 arguments are provided, pass each
101 .I key
102 in succession to
103 .BR getaliasbyname (3)
104 and display the result.
105 .TP
106 .B ethers
107 When one or more
108 .I key
109 arguments are provided, pass each
110 .I key
111 in succession to
112 .BR ether_aton (3)
113 and
114 .BR ether_hostton (3)
115 until a result is obtained, and display the result.
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
125 is provided, use
126 .BR setgrent (3),
127 .BR getgrent (3),
128 and
129 .BR endgrent (3)
130 to enumerate the group database.
131 When one or more
132 .I key
133 arguments are provided, pass each numeric
134 .I key
135 to
136 .BR getgrgid (3)
137 and each nonnumeric
138 .I key
139 to
140 .BR getgrnam (3)
141 and display the result.
142 .TP
143 .B gshadow
144 When no
145 .I key
146 is provided, use
147 .BR setsgent (3),
148 .BR getsgent (3),
149 and
150 .BR endsgent (3)
151 to enumerate the gshadow database.
152 When one or more
153 .I key
154 arguments are provided, pass each
155 .I key
156 in succession to
157 .BR getsgnam (3)
158 and display the result.
159 .TP
160 .B hosts
161 When no
162 .I key
163 is provided, use
164 .BR sethostent (3),
165 .BR gethostent (3),
166 and
167 .BR endhostent (3)
168 to enumerate the hosts database.
169 When one or more
170 .I key
171 arguments are provided, pass each
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
181 is an IPv6 or IPv4 address or not, and display the result.
182 .TP
183 .B initgroups
184 When one or more
185 .I key
186 arguments are provided, pass each
187 .I key
188 in succession to
189 .BR getgrouplist (3)
190 and display the result.
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
200 is provided, pass the
201 .I key
202 to
203 .BR setnetgrent (3)
204 and, using
205 .BR getnetgrent (3)
206 display the resulting string triple
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
218 .BR netgroup ,
219 so either one or three
220 .I keys
221 must be provided.
222 .TP
223 .B networks
224 When no
225 .I key
226 is provided, use
227 .BR setnetent (3),
228 .BR getnetent (3),
229 and
230 .BR endnetent (3)
231 to enumerate the networks database.
232 When one or more
233 .I key
234 arguments are provided, pass each numeric
235 .I key
236 to
237 .BR getnetbyaddr (3)
238 and each nonnumeric
239 .I key
240 to
241 .BR getnetbyname (3)
242 and display the result.
243 .TP
244 .B passwd
245 When no
246 .I key
247 is provided, use
248 .BR setpwent (3),
249 .BR getpwent (3),
250 and
251 .BR endpwent (3)
252 to enumerate the passwd database.
253 When one or more
254 .I key
255 arguments are provided, pass each numeric
256 .I key
257 to
258 .BR getpwuid (3)
259 and each nonnumeric
260 .I key
261 to
262 .BR getpwnam (3)
263 and display the result.
264 .TP
265 .B protocols
266 When no
267 .I key
268 is provided, use
269 .BR setprotoent (3),
270 .BR getprotoent (3),
271 and
272 .BR endprotoent (3)
273 to enumerate the protocols database.
274 When one or more
275 .I key
276 arguments are provided, pass each numeric
277 .I key
278 to
279 .BR getprotobynumber (3)
280 and each nonnumeric
281 .I key
282 to
283 .BR getprotobyname (3)
284 and display the result.
285 .TP
286 .B rpc
287 When no
288 .I key
289 is provided, use
290 .BR setrpcent (3),
291 .BR getrpcent (3),
292 and
293 .BR endrpcent (3)
294 to enumerate the rpc database.
295 When one or more
296 .I key
297 arguments are provided, pass each numeric
298 .I key
299 to
300 .BR getrpcbynumber (3)
301 and each nonnumeric
302 .I key
303 to
304 .BR getrpcbyname (3)
305 and display the result.
306 .TP
307 .B services
308 When no
309 .I key
310 is provided, use
311 .BR setservent (3),
312 .BR getservent (3),
313 and
314 .BR endservent (3)
315 to enumerate the services database.
316 When one or more
317 .I key
318 arguments are provided, pass each numeric
319 .I key
320 to
321 .BR getservbynumber (3)
322 and each nonnumeric
323 .I key
324 to
325 .BR getservbyname (3)
326 and display the result.
327 .TP
328 .B shadow
329 When no
330 .I key
331 is provided, use
332 .BR setspent (3),
333 .BR getspent (3),
334 and
335 .BR endspent (3)
336 to enumerate the shadow database.
337 When one or more
338 .I key
339 arguments are provided, pass each
340 .I key
341 in succession to
342 .BR getspnam (3)
343 and display the result.
344 .RE
345 .SH EXIT STATUS
346 One of the following exit values can be returned by
347 .BR getent :
348 .RS 3
349 .TP 10
350 .B 0
351 Command completed successfully.
352 .TP
353 .B 1
354 Missing arguments, or
355 .I database
356 unknown.
357 .TP
358 .B 2
359 One or more supplied
360 .I key
361 could not be found in the
362 .IR database .
363 .TP
364 .B 3
365 Enumeration not supported on this
366 .IR database .
367 .RE
368 .SH SEE ALSO
369 .BR nsswitch.conf (5)
370 .SH COLOPHON
371 This page is part of release 3.78 of the Linux
372 .I man-pages
373 project.
374 A description of the project,
375 information about reporting bugs,
376 and the latest version of this page,
377 can be found at
378 \%http://www.kernel.org/doc/man\-pages/.