OSDN Git Service

(split) LDP: Update original to LDP v3.38.
[linuxjm/LDP_man-pages.git] / original / man1 / getent.1
1 .\" Copyright (c) 2011, Mark R. Bannister <cambridge@users.sourceforge.net>
2 .\"
3 .\" This is free documentation; you can redistribute it and/or
4 .\" modify it under the terms of the GNU General Public License as
5 .\" published by the Free Software Foundation; either version 2 of
6 .\" the License, or (at your option) any later version.
7 .\"
8 .\" The GNU General Public License's references to "object code"
9 .\" and "executables" are to be interpreted as the output of any
10 .\" document formatting or typesetting system, including
11 .\" intermediate and printed output.
12 .\"
13 .\" This manual is distributed in the hope that it will be useful,
14 .\" but WITHOUT ANY WARRANTY; without even the implied warranty of
15 .\" MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
16 .\" GNU General Public License for more details.
17 .\"
18 .\" You should have received a copy of the GNU General Public
19 .\" License along with this manual; if not, write to the Free
20 .\" Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111,
21 .\" USA.
22 .\"
23 .TH GETENT 1 2011-10-31 "Linux" "User Commands"
24 .SH NAME
25 getent \- get entries from Name Service Switch libraries
26 .SH SYNOPSIS
27 .B "getent
28 .IR database " [" key " ...]"
29 .SH DESCRIPTION
30 The
31 .B getent
32 command displays entries from databases supported by the
33 Name Service Switch libraries,
34 which are configured in
35 .IR /etc/nsswitch.conf .
36 If one or more
37 .I key
38 arguments are provided,
39 then only the entries that match the supplied keys will be displayed.
40 Otherwise, if no
41 .I key
42 is provided, all entries will be displayed (unless the database does not
43 support enumeration).
44 .LP
45 The
46 .I database
47 may be any of those supported by the GNU C Library, listed below:
48 .RS 3
49 .TP 10
50 .B ahosts
51 When no
52 .I key
53 is provided, use
54 .BR sethostent (3),
55 .BR gethostent (3),
56 and
57 .BR endhostent (3)
58 to enumerate the hosts database.
59 This is identical to using
60 .BR hosts .
61 When one or more
62 .I key
63 arguments are provided, pass each
64 .I key
65 in succession to
66 .BR getaddrinfo (3)
67 with the address family
68 .BR AF_UNSPEC ,
69 enumerating each socket address structure returned.
70 .TP
71 .B ahostsv4
72 Same as
73 .BR ahosts ,
74 but use the address family
75 .BR AF_INET .
76 .TP
77 .B ahostsv6
78 Same as
79 .BR ahosts ,
80 but use the address family
81 .BR AF_INET6 .
82 The call to
83 .BR getaddrinfo (3)
84 in this case includes the
85 .B AI_V4MAPPED
86 flag.
87 .TP
88 .B aliases
89 When no
90 .I key
91 is provided, use
92 .BR setaliasent (3),
93 .BR getaliasent (3),
94 and
95 .BR endaliasent (3)
96 to enumerate the aliases database.
97 When one or more
98 .I key
99 arguments are provided, pass each
100 .I key
101 in succession to
102 .BR getaliasbyname (3)
103 and display the result.
104 .TP
105 .B ethers
106 When one or more
107 .I key
108 arguments are provided, pass each
109 .I key
110 in succession to
111 .BR ether_aton (3)
112 and
113 .BR ether_hostton (3)
114 until a result is obtained, and display the result.
115 Enumeration is not supported on
116 .BR ethers ,
117 so a
118 .I key
119 must be provided.
120 .TP
121 .B group
122 When no
123 .I key
124 is provided, use
125 .BR setgrent (3),
126 .BR getgrent (3),
127 and
128 .BR endgrent (3)
129 to enumerate the group database.
130 When one or more
131 .I key
132 arguments are provided, pass each numeric
133 .I key
134 to
135 .BR getgrgid (3)
136 and each nonnumeric
137 .I key
138 to
139 .BR getgrnam (3)
140 and display the result.
141 .TP
142 .B gshadow
143 When no
144 .I key
145 is provided, use
146 .BR setsgent (3),
147 .BR getsgent (3),
148 and
149 .BR endsgent (3)
150 to enumerate the gshadow database.
151 When one or more
152 .I key
153 arguments are provided, pass each
154 .I key
155 in succession to
156 .BR getsgnam (3)
157 and display the result.
158 .TP
159 .B hosts
160 When no
161 .I key
162 is provided, use
163 .BR sethostent (3),
164 .BR gethostent (3),
165 and
166 .BR endhostent (3)
167 to enumerate the hosts database.
168 When one or more
169 .I key
170 arguments are provided, pass each
171 .I key
172 to
173 .BR gethostbyaddr (3)
174 or
175 .BR gethostbyname2 (3),
176 depending on whether a call to
177 .BR inet_pton (3)
178 indicates that the
179 .I key
180 is an IPv6 or IPv4 address or not, and display the result.
181 .TP
182 .B initgroups
183 When one or more
184 .I key
185 arguments are provided, pass each
186 .I key
187 in succession to
188 .BR getgrouplist (3)
189 and display the result.
190 Enumeration is not supported on
191 .BR initgroups ,
192 so a
193 .I key
194 must be provided.
195 .TP
196 .B netgroup
197 When one
198 .I key
199 is provided, pass the
200 .I key
201 to
202 .BR setnetgrent (3)
203 and, using
204 .BR getnetgrent (3)
205 display the resulting string triple
206 .RI ( hostname ", " username ", " domainname ).
207 Alternatively, three
208 .I keys
209 may be provided, which are interpreted as the
210 .IR hostname ,
211 .I username
212 and
213 .I domainname
214 to match to a netgroup name via
215 .BR innetgr (3).
216 Enumeration is not supported on
217 .BR initgroups ,
218 so either one or three
219 .I keys
220 must be provided.
221 .TP
222 .B networks
223 When no
224 .I key
225 is provided, use
226 .BR setnetent (3),
227 .BR getnetent (3),
228 and
229 .BR endnetent (3)
230 to enumerate the networks database.
231 When one or more
232 .I key
233 arguments are provided, pass each numeric
234 .I key
235 to
236 .BR getnetbyaddr (3)
237 and each nonnumeric
238 .I key
239 to
240 .BR getnetbyname (3)
241 and display the result.
242 .TP
243 .B passwd
244 When no
245 .I key
246 is provided, use
247 .BR setpwent (3),
248 .BR getpwent (3),
249 and
250 .BR endpwent (3)
251 to enumerate the passwd database.
252 When one or more
253 .I key
254 arguments are provided, pass each numeric
255 .I key
256 to
257 .BR getpwuid (3)
258 and each nonnumeric
259 .I key
260 to
261 .BR getpwnam (3)
262 and display the result.
263 .TP
264 .B protocols
265 When no
266 .I key
267 is provided, use
268 .BR setprotoent (3),
269 .BR getprotoent (3),
270 and
271 .BR endprotoent (3)
272 to enumerate the protocols database.
273 When one or more
274 .I key
275 arguments are provided, pass each numeric
276 .I key
277 to
278 .BR getprotobynumber (3)
279 and each nonnumeric
280 .I key
281 to
282 .BR getprotobyname (3)
283 and display the result.
284 .TP
285 .B rpc
286 When no
287 .I key
288 is provided, use
289 .BR setrpcent (3),
290 .BR getrpcent (3),
291 and
292 .BR endrpcent (3)
293 to enumerate the rpc database.
294 When one or more
295 .I key
296 arguments are provided, pass each numeric
297 .I key
298 to
299 .BR getrpcbynumber (3)
300 and each nonnumeric
301 .I key
302 to
303 .BR getrpcbyname (3)
304 and display the result.
305 .TP
306 .B services
307 When no
308 .I key
309 is provided, use
310 .BR setservent (3),
311 .BR getservent (3),
312 and
313 .BR endservent (3)
314 to enumerate the services database.
315 When one or more
316 .I key
317 arguments are provided, pass each numeric
318 .I key
319 to
320 .BR getservbynumber (3)
321 and each nonnumeric
322 .I key
323 to
324 .BR getservbyname (3)
325 and display the result.
326 .TP
327 .B shadow
328 When no
329 .I key
330 is provided, use
331 .BR setspent (3),
332 .BR getspent (3),
333 and
334 .BR endspent (3)
335 to enumerate the shadow database.
336 When one or more
337 .I key
338 arguments are provided, pass each
339 .I key
340 in succession to
341 .BR getspnam (3)
342 and display the result.
343 .RE
344 .SH "EXIT STATUS"
345 One of the following exit values can be returned by
346 .BR getent :
347 .RS 3
348 .TP 10
349 .B 0
350 Command completed successfully.
351 .TP
352 .B 1
353 Missing arguments, or
354 .I database
355 unknown.
356 .TP
357 .B 2
358 One or more supplied
359 .I key
360 could not be found in the
361 .IR database .
362 .TP
363 .B 3
364 Enumeration not supported on this
365 .IR database .
366 .RE
367 .SH "SEE ALSO"
368 .BR nsswitch.conf (5)