1GETENT(1)                        User Commands                       GETENT(1)
2
3
4

NAME

6       getent - get entries from Name Service Switch libraries
7

SYNOPSIS

9       getent [option]... database key...
10

DESCRIPTION

12       The  getent  command  displays  entries from databases supported by the
13       Name Service  Switch  libraries,  which  are  configured  in  /etc/nss‐
14       witch.conf.   If  one or more key arguments are provided, then only the
15       entries that match the supplied keys will be displayed.  Otherwise,  if
16       no  key is provided, all entries will be displayed (unless the database
17       does not support enumeration).
18
19       The database may be any of those supported by the GNU C Library, listed
20       below:
21
22          ahosts    When no key is provided, use sethostent(3), gethostent(3),
23                    and endhostent(3) to enumerate the hosts  database.   This
24                    is  identical  to using hosts.  When one or more key argu‐
25                    ments are provided, pass each key in succession to  getad‐
26                    drinfo(3)  with  the address family AF_UNSPEC, enumerating
27                    each socket address structure returned.
28
29          ahostsv4  Same as ahosts, but use the address family AF_INET.
30
31          ahostsv6  Same as ahosts, but use the address family AF_INET6.   The
32                    call   to   getaddrinfo(3)   in  this  case  includes  the
33                    AI_V4MAPPED flag.
34
35          aliases   When  no  key  is  provided,  use  setaliasent(3),  getal‐
36                    iasent(3),  and  endaliasent(3)  to  enumerate the aliases
37                    database.  When one or more key  arguments  are  provided,
38                    pass  each key in succession to getaliasbyname(3) and dis‐
39                    play the result.
40
41          ethers    When one or more key arguments are provided, pass each key
42                    in  succession to ether_aton(3) and ether_hostton(3) until
43                    a result is obtained, and display the result.  Enumeration
44                    is not supported on ethers, so a key must be provided.
45
46          group     When no key is provided, use setgrent(3), getgrent(3), and
47                    endgrent(3) to enumerate the group database.  When one  or
48                    more  key arguments are provided, pass each numeric key to
49                    getgrgid(3) and each nonnumeric  key  to  getgrnam(3)  and
50                    display the result.
51
52          gshadow   When no key is provided, use setsgent(3), getsgent(3), and
53                    endsgent(3) to enumerate the gshadow database.   When  one
54                    or  more key arguments are provided, pass each key in suc‐
55                    cession to getsgnam(3) and display the result.
56
57          hosts     When no key is provided, use sethostent(3), gethostent(3),
58                    and  endhostent(3)  to enumerate the hosts database.  When
59                    one or more key arguments are provided, pass each  key  to
60                    gethostbyaddr(3)   or   gethostbyname2(3),   depending  on
61                    whether a call to inet_pton(3) indicates that the  key  is
62                    an IPv6 or IPv4 address or not, and display the result.
63
64          initgroups
65                    When one or more key arguments are provided, pass each key
66                    in succession to getgrouplist(3) and display  the  result.
67                    Enumeration  is not supported on initgroups, so a key must
68                    be provided.
69
70          netgroup  When one key is provided, pass the key  to  setnetgrent(3)
71                    and,  using  getnetgrent(3)  display  the resulting string
72                    triple (hostname, username,  domainname).   Alternatively,
73                    three  keys  may be provided, which are interpreted as the
74                    hostname, username, and domainname to match to a  netgroup
75                    name via innetgr(3).  Enumeration is not supported on net‐
76                    group, so either one or three keys must be provided.
77
78          networks  When no key is provided, use  setnetent(3),  getnetent(3),
79                    and endnetent(3) to enumerate the networks database.  When
80                    one or more key arguments are provided, pass each  numeric
81                    key  to getnetbyaddr(3) and each nonnumeric key to getnet‐
82                    byname(3) and display the result.
83
84          passwd    When no key is provided, use setpwent(3), getpwent(3), and
85                    endpwent(3) to enumerate the passwd database.  When one or
86                    more key arguments are provided, pass each numeric key  to
87                    getpwuid(3)  and  each  nonnumeric  key to getpwnam(3) and
88                    display the result.
89
90          protocols When no  key  is  provided,  use  setprotoent(3),  getpro‐
91                    toent(3),  and  endprotoent(3)  to enumerate the protocols
92                    database.  When one or more key  arguments  are  provided,
93                    pass each numeric key to getprotobynumber(3) and each non‐
94                    numeric key to getprotobyname(3) and display the result.
95
96          rpc       When no key is provided, use  setrpcent(3),  getrpcent(3),
97                    and  endrpcent(3) to enumerate the rpc database.  When one
98                    or more key arguments are provided, pass each numeric  key
99                    to  getrpcbynumber(3) and each nonnumeric key to getrpcby‐
100                    name(3) and display the result.
101
102          services  When no key is provided, use setservent(3), getservent(3),
103                    and  endservent(3)  to  enumerate  the  services database.
104                    When one or more key arguments are provided, pass each nu‐
105                    meric key to getservbynumber(3) and each nonnumeric key to
106                    getservbyname(3) and display the result.
107
108          shadow    When no key is provided, use setspent(3), getspent(3), and
109                    endspent(3) to enumerate the shadow database.  When one or
110                    more key arguments are provided, pass each key in  succes‐
111                    sion to getspnam(3) and display the result.
112

OPTIONS

114       -s service, --service service
115              Override all databases with the specified service.  (Since glibc
116              2.2.5.)
117
118       -s database:service, --service database:service
119              Override only specified databases with  the  specified  service.
120              The option may be used multiple times, but only the last service
121              for each database will be used.  (Since glibc 2.4.)
122
123       -i, --no-idn
124              Disables  IDN  encoding  in  lookups  for  ahosts/getaddrinfo(3)
125              (Since glibc-2.13.)
126
127       -?, --help
128              Print a usage summary and exit.
129
130       --usage
131              Print a short usage summary and exit.
132
133       -V, --version
134              Print  the  version  number, license, and disclaimer of warranty
135              for getent.
136

EXIT STATUS

138       One of the following exit values can be returned by getent:
139
140          0      Command completed successfully.
141
142          1      Missing arguments, or database unknown.
143
144          2      One or more supplied key could not be found in the database.
145
146          3      Enumeration not supported on this database.
147

SEE ALSO

149       nsswitch.conf(5)
150

COLOPHON

152       This page is part of release 5.13 of the Linux  man-pages  project.   A
153       description  of  the project, information about reporting bugs, and the
154       latest    version    of    this    page,    can     be     found     at
155       https://www.kernel.org/doc/man-pages/.
156
157
158
159Linux                             2021-03-22                         GETENT(1)
Impressum