# phpman > man > getent(1)

> **TLDR:** Get entries from Name Service Switch libraries.
>
- Get list of all groups:
  `getent group`
- See the members of a group:
  `getent group {{group_name}}`
- Get list of all services:
  `getent services`
- Find a username by UID:
  `getent passwd 1000`
- Perform a reverse DNS lookup:
  `getent hosts {{host}}`

*Source: tldr-pages*

---

[GETENT(1)](https://www.chedong.com/phpMan.php/man/GETENT/1/markdown)                                   User Commands                                  [GETENT(1)](https://www.chedong.com/phpMan.php/man/GETENT/1/markdown)



## 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 li‐
       braries, which are configured in _/etc/nsswitch.conf_.  If one or more _key_ arguments  are  pro‐
       vided,  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  enu‐
       meration).

       The _database_ may be any of those supported by the GNU C Library, listed below:

          **ahosts**    When  no _key_ is provided, use [**sethostent**(3)](https://www.chedong.com/phpMan.php/man/sethostent/3/markdown), [**gethostent**(3)](https://www.chedong.com/phpMan.php/man/gethostent/3/markdown), and [**endhostent**(3)](https://www.chedong.com/phpMan.php/man/endhostent/3/markdown) to
                    enumerate the hosts database.  This is identical to using **hosts**.   When  one  or
                    more  _key_  arguments are provided, pass each _key_ in succession to [**getaddrinfo**(3)](https://www.chedong.com/phpMan.php/man/getaddrinfo/3/markdown)
                    with the address family **AF**___**UNSPEC**, enumerating each socket address structure re‐
                    turned.

          **ahostsv4**  Same as **ahosts**, but use the address family **AF**___**INET**.

          **ahostsv6**  Same as **ahosts**, but use the address family **AF**___**INET6**.  The call to [**getaddrinfo**(3)](https://www.chedong.com/phpMan.php/man/getaddrinfo/3/markdown)
                    in this case includes the **AI**___**V4MAPPED** flag.

          **aliases**   When no _key_ is provided, use [**setaliasent**(3)](https://www.chedong.com/phpMan.php/man/setaliasent/3/markdown), [**getaliasent**(3)](https://www.chedong.com/phpMan.php/man/getaliasent/3/markdown), and  [**endaliasent**(3)](https://www.chedong.com/phpMan.php/man/endaliasent/3/markdown)
                    to enumerate the aliases database.  When one or more _key_ arguments are provided,
                    pass each _key_ in succession to [**getaliasbyname**(3)](https://www.chedong.com/phpMan.php/man/getaliasbyname/3/markdown) and display the result.

          **ethers**    When one or more _key_ arguments are provided, pass  each  _key_  in  succession  to
                    **ether**___**[aton**(3)](https://www.chedong.com/phpMan.php/man/aton/3/markdown)  and  **ether**___**[hostton**(3)](https://www.chedong.com/phpMan.php/man/hostton/3/markdown) until a result is obtained, and display the
                    result.  Enumeration is not supported on **ethers**, so a _key_ must be provided.

          **group**     When no _key_ is provided, use [**setgrent**(3)](https://www.chedong.com/phpMan.php/man/setgrent/3/markdown), [**getgrent**(3)](https://www.chedong.com/phpMan.php/man/getgrent/3/markdown), and [**endgrent**(3)](https://www.chedong.com/phpMan.php/man/endgrent/3/markdown)  to  enu‐
                    merate  the  group  database.  When one or more _key_ arguments are provided, pass
                    each numeric _key_ to [**getgrgid**(3)](https://www.chedong.com/phpMan.php/man/getgrgid/3/markdown) and each nonnumeric _key_ to [**getgrnam**(3)](https://www.chedong.com/phpMan.php/man/getgrnam/3/markdown) and  dis‐
                    play the result.

          **gshadow**   When  no  _key_ is provided, use [**setsgent**(3)](https://www.chedong.com/phpMan.php/man/setsgent/3/markdown), [**getsgent**(3)](https://www.chedong.com/phpMan.php/man/getsgent/3/markdown), and [**endsgent**(3)](https://www.chedong.com/phpMan.php/man/endsgent/3/markdown) to enu‐
                    merate the gshadow database.  When one or more _key_ arguments are provided,  pass
                    each _key_ in succession to [**getsgnam**(3)](https://www.chedong.com/phpMan.php/man/getsgnam/3/markdown) and display the result.

          **hosts**     When  no _key_ is provided, use [**sethostent**(3)](https://www.chedong.com/phpMan.php/man/sethostent/3/markdown), [**gethostent**(3)](https://www.chedong.com/phpMan.php/man/gethostent/3/markdown), and [**endhostent**(3)](https://www.chedong.com/phpMan.php/man/endhostent/3/markdown) to
                    enumerate the hosts database.  When one or more _key_ arguments are provided, pass
                    each  _key_  to [**gethostbyaddr**(3)](https://www.chedong.com/phpMan.php/man/gethostbyaddr/3/markdown) or [**gethostbyname2**(3)](https://www.chedong.com/phpMan.php/man/gethostbyname2/3/markdown), depending on whether a call
                    to **inet**___**[pton**(3)](https://www.chedong.com/phpMan.php/man/pton/3/markdown) 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 **get**‐‐
                    [**grouplist**(3)](https://www.chedong.com/phpMan.php/man/grouplist/3/markdown) and display the result.  Enumeration  is  not  supported  on  **init**‐‐
                    **groups**, so a _key_ must be provided.

          **netgroup**  When  one  _key_  is  provided,  pass the _key_ to [**setnetgrent**(3)](https://www.chedong.com/phpMan.php/man/setnetgrent/3/markdown) and, using **getnet**‐‐
                    [**grent**(3)](https://www.chedong.com/phpMan.php/man/grent/3/markdown) display the resulting string triple (_hostname_,  _username_,  _domainname_).
                    Alternatively,  three  _keys_  may be provided, which are interpreted as the _host__‐
                    _name_, _username_, and _domainname_ to match to a netgroup name via [**innetgr**(3)](https://www.chedong.com/phpMan.php/man/innetgr/3/markdown).  Enu‐
                    meration  is not supported on **netgroup**, so either one or three _keys_ must be pro‐
                    vided.

          **networks**  When no _key_ is provided, use [**setnetent**(3)](https://www.chedong.com/phpMan.php/man/setnetent/3/markdown),  [**getnetent**(3)](https://www.chedong.com/phpMan.php/man/getnetent/3/markdown),  and  [**endnetent**(3)](https://www.chedong.com/phpMan.php/man/endnetent/3/markdown)  to
                    enumerate  the  networks database.  When one or more _key_ arguments are provided,
                    pass each numeric _key_ to [**getnetbyaddr**(3)](https://www.chedong.com/phpMan.php/man/getnetbyaddr/3/markdown) and each nonnumeric  _key_  to  **getnetby**‐‐
                    [**name**(3)](https://www.chedong.com/phpMan.php/man/name/3/markdown) and display the result.

          **passwd**    When  no  _key_ is provided, use [**setpwent**(3)](https://www.chedong.com/phpMan.php/man/setpwent/3/markdown), [**getpwent**(3)](https://www.chedong.com/phpMan.php/man/getpwent/3/markdown), and [**endpwent**(3)](https://www.chedong.com/phpMan.php/man/endpwent/3/markdown) to enu‐
                    merate the passwd database.  When one or more _key_ arguments are  provided,  pass
                    each  numeric _key_ to [**getpwuid**(3)](https://www.chedong.com/phpMan.php/man/getpwuid/3/markdown) and each nonnumeric _key_ to [**getpwnam**(3)](https://www.chedong.com/phpMan.php/man/getpwnam/3/markdown) and dis‐
                    play the result.

          **protocols** When no _key_ is provided, use [**setprotoent**(3)](https://www.chedong.com/phpMan.php/man/setprotoent/3/markdown), [**getprotoent**(3)](https://www.chedong.com/phpMan.php/man/getprotoent/3/markdown), and  [**endprotoent**(3)](https://www.chedong.com/phpMan.php/man/endprotoent/3/markdown)
                    to  enumerate  the  protocols database.  When one or more _key_ arguments are pro‐
                    vided, pass each numeric _key_ to [**getprotobynumber**(3)](https://www.chedong.com/phpMan.php/man/getprotobynumber/3/markdown) and each nonnumeric  _key_  to
                    [**getprotobyname**(3)](https://www.chedong.com/phpMan.php/man/getprotobyname/3/markdown) and display the result.

          **rpc**       When  no  _key_  is  provided, use [**setrpcent**(3)](https://www.chedong.com/phpMan.php/man/setrpcent/3/markdown), [**getrpcent**(3)](https://www.chedong.com/phpMan.php/man/getrpcent/3/markdown), and [**endrpcent**(3)](https://www.chedong.com/phpMan.php/man/endrpcent/3/markdown) to
                    enumerate the rpc database.  When one or more _key_ arguments are  provided,  pass
                    each numeric _key_ to [**getrpcbynumber**(3)](https://www.chedong.com/phpMan.php/man/getrpcbynumber/3/markdown) and each nonnumeric _key_ to [**getrpcbyname**(3)](https://www.chedong.com/phpMan.php/man/getrpcbyname/3/markdown)
                    and display the result.

          **services**  When no _key_ is provided, use [**setservent**(3)](https://www.chedong.com/phpMan.php/man/setservent/3/markdown), [**getservent**(3)](https://www.chedong.com/phpMan.php/man/getservent/3/markdown), and [**endservent**(3)](https://www.chedong.com/phpMan.php/man/endservent/3/markdown)  to
                    enumerate  the  services database.  When one or more _key_ arguments are provided,
                    pass each numeric _key_ to [**getservbynumber**(3)](https://www.chedong.com/phpMan.php/man/getservbynumber/3/markdown) and  each  nonnumeric  _key_  to  **get**‐‐
                    [**servbyname**(3)](https://www.chedong.com/phpMan.php/man/servbyname/3/markdown) and display the result.

          **shadow**    When  no  _key_ is provided, use [**setspent**(3)](https://www.chedong.com/phpMan.php/man/setspent/3/markdown), [**getspent**(3)](https://www.chedong.com/phpMan.php/man/getspent/3/markdown), and [**endspent**(3)](https://www.chedong.com/phpMan.php/man/endspent/3/markdown) to enu‐
                    merate the shadow database.  When one or more _key_ arguments are  provided,  pass
                    each _key_ in succession to [**getspnam**(3)](https://www.chedong.com/phpMan.php/man/getspnam/3/markdown) and display the result.

## OPTIONS
### -s --service
              Override all databases with the specified service.  (Since glibc 2.2.5.)

### -s --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)](https://www.chedong.com/phpMan.php/man/getaddrinfo/3/markdown) (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
       [**nsswitch.conf**(5)](https://www.chedong.com/phpMan.php/man/nsswitch.conf/5/markdown)

## 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/>.



Linux                                        2020-12-21                                    [GETENT(1)](https://www.chedong.com/phpMan.php/man/GETENT/1/markdown)
