1.\" 2.\" The contents of this file are subject to the terms of the 3.\" Common Development and Distribution License (the "License"). 4.\" You may not use this file except in compliance with the License. 5.\" 6.\" You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE 7.\" or http://www.opensolaris.org/os/licensing. 8.\" See the License for the specific language governing permissions 9.\" and limitations under the License. 10.\" 11.\" When distributing Covered Code, include this CDDL HEADER in each 12.\" file and include the License file at usr/src/OPENSOLARIS.LICENSE. 13.\" If applicable, add the following below this CDDL HEADER, with the 14.\" fields enclosed by brackets "[]" replaced with your own identifying 15.\" information: Portions Copyright [yyyy] [name of copyright owner] 16.\" 17.\" 18.\" Copyright (C) 1999, Sun Microsystems, Inc. All Rights Reserved 19.\" Copyright (c) 2014 Gary Mills 20.\" Copyright (c) 2018 Peter Tribble 21.\" 22.Dd June 17, 2021 23.Dt GETENT 8 24.Os 25.Sh NAME 26.Nm getent 27.Nd get entries from administrative database 28.Sh SYNOPSIS 29.Nm 30.Ar database 31.Oo Ar key Oc Ns ... 32.Sh DESCRIPTION 33.Nm 34gets a list of entries from the administrative database specified by 35.Ar database . 36The information generally comes from one or more of the sources that are 37specified for the 38.Ar database 39in 40.Pa /etc/nsswitch.conf . 41.Pp 42.Ar database 43is the name of the database to be examined. 44This can be 45.Cm passwd , 46.Cm shadow , 47.Cm group , 48.Cm hosts , 49.Cm ipnodes , 50.Cm services , 51.Cm protocols , 52.Cm ethers , 53.Cm project , 54.Cm networks , 55.Cm netmasks , 56.Cm auth_attr , 57.Cm exec_attr , 58.Cm prof_attr , 59.Cm user_attr , 60or 61.Cm netgroup . 62For each of these databases, 63.Nm 64uses the appropriate library routines described in 65.Xr getpwnam 3C , 66.Xr getspnam 3C , 67.Xr getgrnam 3C , 68.Xr getnetgrent 3C , 69.Xr gethostbyaddr 3NSL , 70.Xr gethostbyname 3NSL , 71.Xr getipnodebyaddr 3SOCKET , 72.Xr getipnodebyname 3SOCKET , 73.Xr getservbyname 3SOCKET , 74.Xr getprotobyname 3SOCKET , 75.Xr ethers 3SOCKET , 76.Xr getprojbyname 3PROJECT , 77.Xr getnetbyname 3SOCKET , 78.Xr getauthattr 3SECDB , 79.Xr getexecattr 3SECDB , 80.Xr getprofattr 3SECDB , 81and 82.Xr getuserattr 3SECDB 83respectively. 84.Pp 85Each 86.Ar key 87must be in a format appropriate for searching on the respective database. 88For example, it can be a username or numeric-uid for 89.Cm passwd ; 90hostname or IP address for 91.Cm hosts ; 92or service, service/protocol, port, or port/proto for 93.Cm services . 94.Pp 95.Nm 96prints out the database entries that match each of the supplied keys, one per 97line, in the format of the matching administrative file: 98.Xr passwd 5 , 99.Xr shadow 5 , 100.Xr group 5 , 101.Xr project 5 , 102.Xr hosts 5 , 103.Xr services 5 , 104.Xr protocols 5 , 105.Xr ethers 5 , 106.Xr netgroup 5 , 107.Xr networks 5 , 108.Xr netmasks 5 , 109.Xr auth_attr 5 , 110.Xr exec_attr 5 , 111.Xr prof_attr 5 , 112or 113.Xr user_attr 5 . 114If no key is given, all entries returned by the corresponding enumeration 115library routine, for example, 116.Xr getpwent 3C 117or 118.Xr gethostent 3NSL , 119are printed. 120Enumeration is not supported on 121.Cm ipnodes , 122.Cm ethers , 123.Cm netgroup , 124or 125.Cm netmasks . 126.Ss Key Interpretation for passwd, group, netgroup, and user_attr Databases 127When 128.Nm 129is invoked with 130.Ar database 131set to 132.Cm passwd , 133each key value is processed as follows: 134.Bl -bullet 135.It 136If the key value consists only of numeric characters, 137.Nm 138assumes that the key value is a numeric user ID and searches the 139.Cm passwd 140database for a matching user ID. 141.It 142If the user ID is not found in the 143.Cm passwd 144database or if the key value contains any non-numeric characters, 145.Nm 146assumes the key value is a user name and searches the 147.Cm passwd 148database for a matching user name. 149.El 150.Pp 151When 152.Nm 153is invoked with 154.Ar database 155set to 156.Cm group , 157each key value is processed as follows: 158.Bl -bullet 159.It 160If the key value consists only of numeric characters, 161.Nm 162assumes that the key value is a numeric group ID and searches the 163.Cm group 164database for a matching group ID. 165.It 166If the group ID is not found in the 167.Cm group 168database or if the key value contains any non-numeric characters, 169.Nm 170assumes the key value is a group name and searches the 171.Cm group 172database for a matching group name. 173.El 174.Pp 175When 176.Nm 177is invoked with 178.Ar database 179set to 180.Cm netgroup , 181only a single lookup key is supported, which must be in the following format: 182.Bd -ragged -offset Ds 183.Ar netgroup Oo Ar host Ar user Ar domain Oc 184.Ed 185.Pp 186Specifying only the 187.Ar netgroup 188name will result in entries from the selected netgroup being displayed as 189string triples 190.Pq hostname, username, domain , 191in a format compatible with 192.Xr netgroup 5 . 193.Pp 194Specifying the 195.Ar netgroup 196along with 197.Ar host , 198.Ar user 199and 200.Ar domain 201will filter the netgroup display based on these entries. 202An asterisk 203.Pq \&* 204can be used as a wildcard for the 205.Ar host , 206.Ar user 207or 208.Ar domain 209fields. 210.Pp 211Since the 212.Cm netgroup 213database does not support enumeration, a lookup key must always be specified. 214.Pp 215When 216.Nm 217is invoked with 218.Ar database 219set to 220.Cm user_attr , 221each key value is processed as follows: 222.Bl -bullet 223.It 224If the key value consists only of numeric characters, 225.Nm 226assumes that the key value is a numeric user ID and searches the 227.Cm passwd 228database for a matching user name, which is then used as the key for 229.Cm user_attr . 230.It 231If the user ID is not found in the 232.Cm passwd 233database or if the key value contains any non-numeric characters, 234.Nm 235assumes the key value is a user name and searches the 236.Cm user_attr 237database for a matching entry. 238.El 239.Sh FILES 240.Bl -tag -width Pa 241.It Pa /etc/nsswitch.conf 242name service switch configuration file 243.It Pa /etc/passwd 244password file 245.It Pa /etc/shadow 246shadowed password file 247.It Pa /etc/group 248group file 249.It Pa /etc/inet/hosts 250IPv4 and IPv6 host name database 251.It Pa /etc/services 252Internet services and aliases 253.It Pa /etc/project 254project file 255.It Pa /etc/protocols 256protocol name database 257.It Pa /etc/ethers 258Ethernet address to hostname database or domain 259.It Pa /etc/networks 260network name database 261.It Pa /etc/netmasks 262network mask database 263.It Pa /etc/netgroup 264network group database 265.It Pa /etc/user_attr 266extended user attributes database 267.It Pa /etc/security/auth_attr 268authorization description database 269.It Pa /etc/security/exec_attr 270execution profiles database 271.It Pa /etc/security/prof_attr 272profile description database 273.El 274.Sh EXIT STATUS 275The following exit values are returned: 276.Pp 277.Bl -tag -width Ds -compact 278.It Sy 0 279Successful completion. 280.It Sy 1 281Command syntax was incorrect, an invalid option was used, or an internal error 282occurred. 283.It Sy 2 284At least one of the specified entry names was not found in the database. 285.It Sy 3 286There is no support for enumeration on this database. 287.El 288.Sh SEE ALSO 289.Xr getgrnam 3C , 290.Xr getnetgrent 3C , 291.Xr getpwnam 3C , 292.Xr getspnam 3C , 293.Xr gethostbyaddr 3NSL , 294.Xr gethostbyname 3NSL , 295.Xr gethostent 3NSL , 296.Xr getprojbyname 3PROJECT , 297.Xr getauthattr 3SECDB , 298.Xr getexecattr 3SECDB , 299.Xr getprofattr 3SECDB , 300.Xr getuserattr 3SECDB , 301.Xr ethers 3SOCKET , 302.Xr getipnodebyaddr 3SOCKET , 303.Xr getipnodebyname 3SOCKET , 304.Xr getnetbyname 3SOCKET , 305.Xr getprotobyname 3SOCKET , 306.Xr getservbyname 3SOCKET , 307.Xr auth_attr 5 , 308.Xr ethers 5 , 309.Xr exec_attr 5 , 310.Xr group 5 , 311.Xr hosts 5 , 312.Xr netmasks 5 , 313.Xr networks 5 , 314.Xr nsswitch.conf 5 , 315.Xr passwd 5 , 316.Xr prof_attr 5 , 317.Xr project 5 , 318.Xr protocols 5 , 319.Xr services 5 , 320.Xr shadow 5 , 321.Xr user_attr 5 , 322.Xr attributes 7 323