1 GETENT(1M)                   Maintenance Commands                   GETENT(1M)
   2 
   3 
   4 
   5 NAME
   6        getent - get entries from administrative database
   7 
   8 SYNOPSIS
   9        getent database [key]...
  10 
  11 
  12 DESCRIPTION
  13        getent gets a list of entries from the administrative database
  14        specified by database. The information generally comes from one or more
  15        of the sources that are specified for the database in
  16        /etc/nsswitch.conf.
  17 
  18 
  19        database is the name of the database to be examined. This can be
  20        passwd, shadow, group, hosts, ipnodes, services, protocols, ethers,
  21        project, networks, netmasks, or netgroup.  For each of these databases,
  22        getent uses the appropriate library routines described in getpwnam(3C),
  23        getspnam(3C), getgrnam(3C), gethostbyaddr(3NSL), gethostbyname(3NSL),
  24        getipnodebyaddr(3SOCKET), getipnodebyname(3SOCKET),
  25        getservbyname(3SOCKET), getprotobyname(3SOCKET), ethers(3SOCKET),
  26        getprojbyname(3PROJECT), getnetbyname(3SOCKET), or getnetgrent(3C)
  27        respectively.
  28 
  29 
  30        Each key must be in a format appropriate for searching on the
  31        respective database. For example, it can be a username or numeric-uid
  32        for passwd; hostname or IP address for hosts; or service,
  33        service/protocol, port, or port/proto for services.
  34 
  35 
  36        getent prints out the database entries that match each of the supplied
  37        keys, one per line, in the format of the matching administrative file:
  38        passwd(4), shadow(4), group(4), project(4), hosts(4), services(4),
  39        protocols(4), ethers(3SOCKET), networks(4), or netmasks(4). If no key
  40        is given, all entries returned by the corresponding enumeration library
  41        routine, for example, getpwent() or gethostent(), are printed.
  42        Enumeration is not supported on ipnodes.
  43 
  44    Key Interpretation for passwd and group Databases
  45        When getent is invoked with database set to passwd, each key value is
  46        processed as follows:
  47 
  48            o      If the key value consists only of numeric characters, getent
  49                   assumes that the key value is a numeric user ID and searches
  50                   the user database for a matching user ID.
  51 
  52            o      If the user ID is not found in the user database or if the
  53                   key value contains any non-numeric characters, getent
  54                   assumes the key value is a user name and searches the user
  55                   database for a matching user name.
  56 
  57 
  58        Similarly, when getent is invoked with database set to group, each key
  59        value is processed as follows:
  60 
  61            o      If the key value consists only of numeric characters, getent
  62                   assumes that the key value is a numeric group ID and
  63                   searches the group database for a matching group ID.
  64 
  65            o      If the group ID is not found in the group database or if the
  66                   key value contains any non-numeric characters, getent
  67                   assumes the key value is a group name and searches the group
  68                   database for a matching group name.
  69 
  70 EXIT STATUS
  71        The following exit values are returned:
  72 
  73        0
  74             Successful completion.
  75 
  76 
  77        1
  78             Command syntax was incorrect, an invalid option was used, or an
  79             internal error occurred.
  80 
  81 
  82        2
  83             At least one of the specified entry names was not found in the
  84             database.
  85 
  86 
  87        3
  88             There is no support for enumeration on this database.
  89 
  90 
  91 FILES
  92        /etc/nsswitch.conf
  93                              name service switch configuration file
  94 
  95 
  96        /etc/passwd
  97                              password file
  98 
  99 
 100        /etc/shadow
 101                              shadowed password file
 102 
 103 
 104        /etc/group
 105                              group file
 106 
 107 
 108        /etc/inet/hosts
 109                              IPv4 and IPv6 host name database
 110 
 111 
 112        /etc/services
 113                              Internet services and aliases
 114 
 115 
 116        /etc/project
 117                              project file
 118 
 119 
 120        /etc/protocols
 121                              protocol name database
 122 
 123 
 124        /etc/ethers
 125                              Ethernet address to hostname database or domain
 126 
 127 
 128        /etc/networks
 129                              network name database
 130 
 131 
 132        /etc/netmasks
 133                              network mask database
 134 
 135 
 136 SEE ALSO
 137        ethers(3SOCKET), getgrnam(3C), gethostbyaddr(3NSL),
 138        gethostbyname(3NSL), gethostent(3NSL), getipnodebyaddr(3SOCKET),
 139        getipnodebyname(3SOCKET), getnetbyname(3SOCKET),
 140        getprojbyname(3PROJECT), getprotobyname(3SOCKET), getpwnam(3C),
 141        getservbyname(3SOCKET), group(4), hosts(4), netmasks(4), networks(4),
 142        nsswitch.conf(4), passwd(4), project(4), protocols(4), services(4),
 143        attributes(5)
 144 
 145 
 146 
 147                                 March 14, 2014                      GETENT(1M)