Home

getent

getent is a command-line utility on many Unix-like systems that retrieves entries from administrative databases. It relies on the Name Service Switch (NSS) configuration to query databases defined in /etc/nsswitch.conf. Entries may come from local files such as /etc/passwd, /etc/group, and /etc/hosts, or from remote services like LDAP, NIS, or SSSD, depending on the system’s NSS setup. The tool provides a uniform way to obtain information about users, groups, hosts, and other entities regardless of the underlying source.

Usage and syntax: getent database [keys...]. The database is the name of the NSS source to query

Notes: Output is plain text and database-specific. For passwd and group, lines are typically colon-separated fields;

(for
example,
passwd,
group,
hosts,
services,
protocols,
networks,
ethers,
or
aliases).
If
no
keys
are
given,
getent
prints
all
entries
from
the
specified
database.
Examples
include:
getent
passwd
to
list
all
user
entries,
getent
passwd
root
to
show
the
root
user,
getent
hosts
example.com
to
resolve
a
hostname,
getent
services
http
to
find
the
service
entry
for
HTTP,
and
getent
group
sudo
to
display
the
sudo
group
membership.
Access
to
certain
databases,
such
as
shadow,
may
require
elevated
privileges.
for
hosts,
multiple
records
may
be
shown;
for
others,
the
format
varies
by
database.
getent
is
a
common
tool
for
testing
NSS
configuration,
troubleshooting
login
and
name
resolution
issues,
and
validating
that
various
data
sources
are
being
consulted
as
expected.