getent - get entries from administrative database
getent database [key]...
getent gets a list of entries from the administrative database specified by database. The information generally comes from one or more of the sources that are specified for the database in /etc/nsswitch.conf.
database is the name of the database to be examined. This can be passwd, group, hosts, ipnodes, services, ethers, networks, netmask, project, user_attr, prof_attr, auth_attr, exec_attr, netgroup, initgroup, rpc, or shadow. For each of these databases, getent uses the appropriate library routines described in getpwnam(3C), getgrnam(3C), gethostbyaddr (3C) , gethostbyname (3C) , getipnodebyaddr (3C) , getipnodebyname (3C) , getservbyname (3C) , getprotobyname (3C) , ether_hostton (3C) , getnetbyname (3C) , getprojbyname(3PROJECT), getusernam(3C), getprofattr(3C), getauthattr(3C), getexecattr(3C), getnetgrent(3C), getgrouplist(3C), getrpcbyname (3C) , or getspnam(3C) respectively.
Each key must be in a format appropriate for searching on the respective database. For example, it can be a username or numeric-uid for passwd; hostname or IP address for hosts; or service, service/protocol, port, or port/proto for services.
getent prints out the database entries that match each of the supplied keys, one per line, in the format of the matching administrative file: passwd(4), group(4), project(4), networks(4), netmasks(4), user_attr(4), prof_attr(4), auth_attr(4), or exec_attr(4). The key for exec_attr(4) is a profile name. If no key is given, all entries returned by the corresponding enumeration library routine, for example, getpwent() or gethostent(), are printed. Enumeration is not supported on ipnodes, ethers, netgroup and netmasks.
For netgroup, you can either specify the netgroup name for the triples to be displayed or the netgroup name plus the triples (hostname, username and domainname) can be specified as keys. It then returns if a triple matches. Wildcards for triples can be specified as *.
When getent is invoked with database set to passwd, each key value is processed as follows:
If the key value consists only of numeric characters, getent assumes that the key value is a numeric user ID and searches the user database for a matching user ID.
If the user ID is not found in the user database or if the key value contains any non-numeric characters, getent assumes the key value is a user name and searches the user database for a matching user name.
Similarly, when getent is invoked with database set to group, each key value is processed as follows:
If the key value consists only of numeric characters, getent assumes that the key value is a numeric group ID and searches the group database for a matching group ID.
If the group ID is not found in the group database or if the key value contains any non-numeric characters, getent assumes the key value is a group name and searches the group database for a matching group name.
When getent is invoked with database set to user_attr(4), each key value is processed as follows:
If the key value consists only of numeric characters, getent assumes that the key value is a numeric user ID and searches the user database for a matching user ID.
If the key value contains any non-numeric characters, getent assumes the key value is a user name and searches the user database for a matching user name.
The following example lists the entire contents of the protocols database.
# getent protocolsExample 2 Listing the Contents of the auto_master Automount Map
The following example lists the entire contents of the auto_master automount map.
# getent automount/auto_masterExample 3 Displaying the Entries for a User in the auto_home Automount Map
The following example displays the entry for jsmith in the auto_home automount map.
# getent automount/auto_home jsmithExample 4 Displaying if the netgroup Triple Matches
The following example displays if the netgroup triple matches the specified netgroup. Wildcards (*) can be specified as parts of the triple.
A match is shown as the netgroup triple equal to 1.
# getent netgroup workstations fred.com * *
The following exit values are returned:
Successful completion.
Command syntax was incorrect, an invalid option was used, or an internal error occurred.
At least one of the specified entry names was not found in the database.
There is no support for enumeration on this database.
name service switch configuration file
password file
group file
IPv4 and IPv6 host name database
Internet services and aliases
project file
protocol name database
Ethernet address to hostname database or domain
network name database
network mask database
Extended user attributes
Profile description database
Authorization description
Execution profiles database
See attributes(5) for descriptions of the following attributes:
|
ethers(3SOCKET), getgrnam(3C), gethostbyaddr(3NSL), gethostbyname(3NSL), gethostent(3NSL), getipnodebyaddr(3SOCKET), getipnodebyname(3SOCKET), getnetbyname(3SOCKET), getprojbyname(3PROJECT), getprotobyname(3SOCKET), getpwnam(3C), getservbyname(3SOCKET), getauthattr(3C), getexecattr(3C), getprofattr(3C), getuserattr(3C), ethers(4), group(4), hosts(4), netmasks(4), networks(4), nsswitch.conf(4), auth_attr(4), exec_attr(4), passwd(4), prof_attr(4), project(4), protocols(4), services(4), user_attr(4), attributes(5)