GETENT(1M) Maintenance Commands GETENT(1M)

NAME


getent - get entries from administrative database

SYNOPSIS


getent database [key]...

DESCRIPTION


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,
shadow, group, hosts, ipnodes, services, protocols, ethers, project,
networks, netmasks, auth_attr, exec_attr, prof_attr, or user_attr. For
each of these databases, getent uses the appropriate library routines
described in getpwnam(3C), getspnam(3C), getgrnam(3C), gethostbyaddr(3NSL),
gethostbyname(3NSL), getipnodebyaddr(3SOCKET), getipnodebyname(3SOCKET),
getservbyname(3SOCKET), getprotobyname(3SOCKET), ethers(3SOCKET),
getprojbyname(3PROJECT), getnetbyname(3SOCKET), getauthattr(3SECDB),
getexecattr(3SECDB), getprofattr(3SECDB), and getuserattr(3SECDB)
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), shadow(4), group(4), project(4), hosts(4), services(4),
protocols(4), ethers(4), networks(4), netmasks(4), auth_attr(4),
exec_attr(4), prof_attr(4), or user_attr(4). If no key is given, all
entries returned by the corresponding enumeration library routine, for
example, getpwent(3C) or gethostent(3NSL), are printed. Enumeration is not
supported on ipnodes, ethers, or netmasks.

Key Interpretation for passwd, group, and user_attr Databases
When getent is invoked with database set to passwd, each key value is
processed as follows:

+o If the key value consists only of numeric characters, getent assumes
that the key value is a numeric user ID and searches the passwd
database for a matching user ID.

+o If the user ID is not found in the passwd database or if the key value
contains any non-numeric characters, getent assumes the key value is a
user name and searches the passwd database for a matching user name.

When getent is invoked with database set to group, each key value is
processed as follows:

+o 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.

+o 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, each key value is
processed as follows:

+o If the key value consists only of numeric characters, getent assumes
that the key value is a numeric user ID and searches the passwd
database for a matching user name, which is then used as the key for
user_attr.

+o If the user ID is not found in the passwd database or if the key value
contains any non-numeric characters, getent assumes the key value is a
user name and searches the user_attr database for a matching entry.

FILES


/etc/nsswitch.conf name service switch configuration file

/etc/passwd password file

/etc/shadow shadowed password file

/etc/group group file

/etc/inet/hosts IPv4 and IPv6 host name database

/etc/services Internet services and aliases

/etc/project project file

/etc/protocols protocol name database

/etc/ethers Ethernet address to hostname database or
domain

/etc/networks network name database

/etc/netmasks network mask database

/etc/user_attr extended user attributes database

/etc/security/auth_attr authorization description database

/etc/security/exec_attr execution profiles database

/etc/security/prof_attr profile description database

EXIT STATUS


The following exit values are returned:

0 Successful completion.
1 Command syntax was incorrect, an invalid option was used, or an
internal error occurred.
2 At least one of the specified entry names was not found in the
database.
3 There is no support for enumeration on this database.

SEE ALSO


getgrnam(3C), getpwnam(3C), getspnam(3C), gethostbyaddr(3NSL),
gethostbyname(3NSL), gethostent(3NSL), getprojbyname(3PROJECT),
getauthattr(3SECDB), getexecattr(3SECDB), getprofattr(3SECDB),
getuserattr(3SECDB), ethers(3SOCKET), getipnodebyaddr(3SOCKET),
getipnodebyname(3SOCKET), getnetbyname(3SOCKET), getprotobyname(3SOCKET),
getservbyname(3SOCKET), auth_attr(4), ethers(4), exec_attr(4), group(4),
hosts(4), netmasks(4), networks(4), nsswitch.conf(4), passwd(4),
prof_attr(4), project(4), protocols(4), services(4), shadow(4),
user_attr(4), attributes(5)

illumos August 13, 2018 illumos