OSDN Git Service

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