xref: /netbsd-src/usr.bin/getent/getent.1 (revision bdc22b2e01993381dcefeff2bc9b56ca75a4235c)
1.\"	$NetBSD: getent.1,v 1.25 2017/10/23 01:06:05 wiz Exp $
2.\"
3.\" Copyright (c) 2004 The NetBSD Foundation, Inc.
4.\" All rights reserved.
5.\"
6.\" This code is derived from software contributed to The NetBSD Foundation
7.\" by Luke Mewburn.
8.\"
9.\" Redistribution and use in source and binary forms, with or without
10.\" modification, are permitted provided that the following conditions
11.\" are met:
12.\" 1. Redistributions of source code must retain the above copyright
13.\"    notice, this list of conditions and the following disclaimer.
14.\" 2. Redistributions in binary form must reproduce the above copyright
15.\"    notice, this list of conditions and the following disclaimer in the
16.\"    documentation and/or other materials provided with the distribution.
17.\"
18.\" THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
19.\" ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
20.\" TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
21.\" PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS
22.\" BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
23.\" CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
24.\" SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
25.\" INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
26.\" CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
27.\" ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
28.\" POSSIBILITY OF SUCH DAMAGE.
29.\"
30.Dd October 11, 2011
31.Dt GETENT 1
32.Os
33.Sh NAME
34.Nm getent ,
35.Nm getcap
36.Nd get entries from administrative databases
37.Sh SYNOPSIS
38.Nm getent
39.Ar database
40.Op Ar key ...
41.Nm getcap
42.Ar database
43.Op Ar key ...
44.Sh DESCRIPTION
45The
46.Nm
47program retrieves and displays entries from the administrative
48database specified by
49.Ar database ,
50using the lookup order specified in
51.Xr nsswitch.conf 5 .
52The display format for a given
53.Ar database
54is as per the
55.Dq traditional
56file format for that database.
57.Pp
58.Ar database
59may be one of:
60.Bl -column "protocols" "user:passwd:uid:gid:gecos:home_dir:shell" -offset indent -compact
61.It Sy Database Ta Sy Display format
62.It disktab Ta entry
63.It ethers Ta address name
64.It gettytab Ta entry
65.It group Ta group:passwd:gid:[member[,member]...]
66.It hosts Ta address name [alias ...]
67.It netgroup Ta (host,user,domain) [...]
68.It networks Ta name network [alias ...]
69.It passwd Ta user:passwd:uid:gid:gecos:home_dir:shell
70.It printcap Ta entry
71.It protocols Ta name protocol [alias ...]
72.It rpc Ta name number [alias ...]
73.It services Ta name port/protocol [alias ...]
74.It shells Ta /path/to/shell
75.El
76.Pp
77If one or more
78.Ar key
79arguments are provided, they will be looked up in
80.Ar database
81using the appropriate function.
82For example,
83.Sy passwd
84supports a numeric UID or user name;
85.Sy hosts
86supports an IPv4 address, IPv6 address, or host name;
87and
88.Sy services
89supports a service name, service name/protocol name, numeric port, or
90numeric port/protocol name.
91.Pp
92If no
93.Ar key
94is provided and
95.Ar database
96supports enumeration, all entries for
97.Ar database
98will be retrieved using the appropriate enumeration function and printed.
99.Pp
100For
101.Xr cgetcap 3
102style databases
103.Sy ( disktab ,
104.Sy printcap )
105specifying a key, lists the entry for that key, and specifying more arguments
106after the key are used as fields in that key, and only the values of the keys
107are returned.
108For boolean keys
109.Dv true
110is returned if the key is found.
111If a key is not found, then
112.Dv false
113is always
114returned.
115.Sh DIAGNOSTICS
116.Nm
117exits 0 on success,
1181 if there was an error in the command syntax,
1192 if one of the specified key names was not found in
120.Ar database ,
121or 3 if there is no support for enumeration on
122.Ar database .
123.Sh SEE ALSO
124.Xr cgetcap 3 ,
125.Xr disktab 5 ,
126.Xr ethers 5 ,
127.Xr gettytab 5 ,
128.Xr group 5 ,
129.Xr hosts 5 ,
130.Xr networks 5 ,
131.Xr nsswitch.conf 5 ,
132.Xr passwd 5 ,
133.Xr printcap 5 ,
134.Xr protocols 5 ,
135.Xr rpc 5 ,
136.Xr services 5 ,
137.Xr shells 5
138.Sh HISTORY
139A
140.Nm
141command appeared in
142.Nx 3.0 .
143It was based on the command of the same name in Solaris and Linux.
144