getent (1) Linux Manual Page
NAME
getent – get entries from Name Service Switch libraries
SYNOPSIS
getent [option]… database key…
DESCRIPTION
The getent command displays entries from databases supported by the Name Service Switch libraries, which are configured in /etc/nsswitch.conf. If one or more key arguments are provided, then only the entries that match the supplied keys will be displayed. Otherwise, if no key is provided, all entries will be displayed (unless the database does not support enumeration).
The database may be any of those supported by the GNU C Library, listed below:
-
ahosts- When no key is provided, use
sethostent(3),gethostent(3), andendhostent(3) to enumerate the hosts database. This is identical to usinghosts. When one or more key arguments are provided, pass each key in succession togetaddrinfo(3) with the address familyAF_UNSPEC, enumerating each socket address structure returned. ahostsv4- Same as
ahosts, but use the address familyAF_INET. ahostsv6- Same as
ahosts, but use the address familyAF_INET6. The call togetaddrinfo(3) in this case includes theAI_V4MAPPEDflag. aliases- When no key is provided, use
setaliasent(3),getaliasent(3), andendaliasent(3) to enumerate the aliases database. When one or more key arguments are provided, pass each key in succession togetaliasbyname(3) and display the result. ethers- When one or more key arguments are provided, pass each key in succession to
ether_aton(3) andether_hostton(3) until a result is obtained, and display the result. Enumeration is not supported onethers, so a key must be provided. group- When no key is provided, use
setgrent(3),getgrent(3), andendgrent(3) to enumerate the group database. When one or more key arguments are provided, pass each numeric key togetgrgid(3) and each nonnumeric key togetgrnam(3) and display the result. gshadow- When no key is provided, use
setsgent(3),getsgent(3), andendsgent(3) to enumerate the gshadow database. When one or more key arguments are provided, pass each key in succession togetsgnam(3) and display the result. hosts- When no key is provided, use
sethostent(3),gethostent(3), andendhostent(3) to enumerate the hosts database. When one or more key arguments are provided, pass each key togethostbyaddr(3) orgethostbyname2(3), depending on whether a call toinet_pton(3) indicates that the key is an IPv6 or IPv4 address or not, and display the result. initgroups- When one or more key arguments are provided, pass each key in succession to
getgrouplist(3) and display the result. Enumeration is not supported oninitgroups, so a key must be provided. netgroup- When one key is provided, pass the key to
setnetgrent(3) and, usinggetnetgrent(3) display the resulting string triple (hostname, username, domainname). Alternatively, three keys may be provided, which are interpreted as the hostname, username, and domainname to match to a netgroup name viainnetgr(3). Enumeration is not supported onnetgroup, so either one or three keys must be provided. networks- When no key is provided, use
setnetent(3),getnetent(3), andendnetent(3) to enumerate the networks database. When one or more key arguments are provided, pass each numeric key togetnetbyaddr(3) and each nonnumeric key togetnetbyname(3) and display the result. passwd- When no key is provided, use
setpwent(3),getpwent(3), andendpwent(3) to enumerate the passwd database. When one or more key arguments are provided, pass each numeric key togetpwuid(3) and each nonnumeric key togetpwnam(3) and display the result. protocols- When no key is provided, use
setprotoent(3),getprotoent(3), andendprotoent(3) to enumerate the protocols database. When one or more key arguments are provided, pass each numeric key togetprotobynumber(3) and each nonnumeric key togetprotobyname(3) and display the result. rpc- When no key is provided, use
setrpcent(3),getrpcent(3), andendrpcent(3) to enumerate the rpc database. When one or more key arguments are provided, pass each numeric key togetrpcbynumber(3) and each nonnumeric key togetrpcbyname(3) and display the result. services- When no key is provided, use
setservent(3),getservent(3), andendservent(3) to enumerate the services database. When one or more key arguments are provided, pass each numeric key togetservbynumber(3) and each nonnumeric key togetservbyname(3) and display the result. shadow- When no key is provided, use
setspent(3),getspent(3), andendspent(3) to enumerate the shadow database. When one or more key arguments are provided, pass each key in succession togetspnam(3) and display the result.
OPTIONS
-sservice,–serviceservice- Override all databases with the specified service. (Since glibc 2.2.5.)
-sdatabase:service, –service database:service- Override only specified databases with the specified service. The option may be used multiple times, but only the last service for each database will be used. (Since glibc 2.4.)
-i,–no-idn- Disables IDN encoding in lookups for
ahosts/getaddrinfo(3) (Since glibc-2.13.) -?,–help- Print a usage summary and exit.
–usage- Print a short usage summary and exit.
-V,–version- Print the version number, license, and disclaimer of warranty for
getent.
EXIT STATUS
One of the following exit values can be returned by getent:
-
0- Command completed successfully.
1- Missing arguments, or database unknown.
2- One or more supplied key could not be found in the database.
3- Enumeration not supported on this database.
SEE ALSO
COLOPHON
This page is part of release 5.10 of the Linux man-pages project. A description of the project, information about reporting bugs, and the latest version of this page, can be found at https://www.kernel.org/doc/man-pages/.
