getent(1)

๐Ÿ’– NAME ๐Ÿ’–

getent โ€” get entries from Name Service Switch libraries โœจ

(no but fr, "getent" = "get entries", and she's about to become your new bestie for looking stuff up)


โœจ SYNOPSIS โœจ

getent [option ...] database key ...

๐Ÿฆ‹ DESCRIPTION ๐Ÿฆ‹

Okay so picture this, bestie: the getent command displays entries from databases supported by the Name Service Switch libraries, which are configured in /etc/nsswitch.conf. That's the whole vibe.

If you pass one or more key arguments, 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, in which case, sorry babe, no full dump for you. ๐Ÿ˜ญ)

The database may be any of those supported by the GNU C Library, listed below, and honestly? It's giving menu. Let's go:

ahosts ๐Ÿ’ซ

When no key is provided, use sethostent(3), gethostent(3), and endhostent(3) to enumerate the hosts database. This is identical to using hosts(5). When one or more key arguments are provided, pass each key in succession to getaddrinfo(3) with the address family AF_UNSPEC, enumerating each socket address structure returned.

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) in this case includes the AI_V4MAPPED flag.

aliases ๐ŸŽ€

When no key is provided, use setaliasent(3), getaliasent(3), and endaliasent(3) to enumerate the aliases database. When one or more key arguments are provided, pass each key in succession to getaliasbyname(3) and display the result.

ethers ๐ŸŒธ

When one or more key arguments are provided, pass each key in succession to ether_aton(3) and ether_hostton(3) 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), getgrent(3), and endgrent(3) to enumerate the group database. When one or more key arguments are provided, pass each numeric key to getgrgid(3) and each nonnumeric key to getgrnam(3) and display the result.

gshadow ๐Ÿซถ

When no key is provided, use setsgent(3), getsgent(3), and endsgent(3) to enumerate the gshadow database. When one or more key arguments are provided, pass each key in succession to getsgnam(3) and display the result.

hosts ๐ŸŒ

When no key is provided, use sethostent(3), gethostent(3), and endhostent(3) to enumerate the hosts database. When one or more key arguments are provided, pass each key to gethostbyaddr(3) or gethostbyname2(3), depending on whether a call to inet_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 on initgroups, so a key must be provided.

netgroup ๐Ÿ“

When one key is provided, pass the key to setnetgrent(3) and, using getnetgrent(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 via innetgr(3). Enumeration is not supported on netgroup, so either one or three keys must be provided โ€” no in-between, she's picky. ๐Ÿ’…

networks ๐ŸŒˆ

When no key is provided, use setnetent(3), getnetent(3), and endnetent(3) to enumerate the networks database. When one or more key arguments are provided, pass each numeric key to getnetbyaddr(3) and each nonnumeric key to getnetbyname(3) and display the result.

passwd ๐Ÿ”‘

When no key is provided, use setpwent(3), getpwent(3), and endpwent(3) to enumerate the passwd database. When one or more key arguments are provided, pass each numeric key to getpwuid(3) and each nonnumeric key to getpwnam(3) and display the result.

protocols โœจ

When no key is provided, use setprotoent(3), getprotoent(3), and endprotoent(3) to enumerate the protocols database. When one or more key arguments are provided, pass each numeric key to getprotobynumber(3) and each nonnumeric key to getprotobyname(3) and display the result.

rpc ๐Ÿ’ซ

When no key is provided, use setrpcent(3), getrpcent(3), and endrpcent(3) to enumerate the rpc database. When one or more key arguments are provided, pass each numeric key to getrpcbynumber(3) and each nonnumeric key to getrpcbyname(3) and display the result.

services ๐ŸŽ€

When no key is provided, use setservent(3), getservent(3), and endservent(3) to enumerate the services database. When one or more key arguments are provided, pass each numeric key to getservbynumber(3) and each nonnumeric key to getservbyname(3) and display the result.

shadow ๐ŸŒ™

When no key is provided, use setspent(3), getspent(3), and endspent(3) to enumerate the shadow database. When one or more key arguments are provided, pass each key in succession to getspnam(3) and display the result.


๐Ÿ’… OPTIONS ๐Ÿ’…

The flags, bestie. Every single one, no skips:

  • --service service, -s service โ€” Override all databases with the specified service. (Since glibc 2.2.5.) โœ…
  • --service database:service, -s database:service โ€” Override only the specified database 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.) ๐Ÿ‘€
  • --no-idn, -i โ€” Disables IDN encoding in lookups for ahosts/getaddrinfo(3) (Since glibc-2.13.)
  • --help, -? โ€” Print a usage summary and exit. Bye! ๐Ÿ‘‹
  • --usage โ€” Print a short usage summary and exit. (Shorter. Lil snack version. ๐Ÿ“)
  • --version, -V โ€” Print the version number, license, and disclaimer of warranty for getent. The legal-ese speedrun. ๐Ÿ“œ

๐Ÿšช EXIT STATUS ๐Ÿšช

One of the following exit values can be returned by getent:

  1. 0 โ€” Command completed successfully. Slay. ๐Ÿ’–
  2. 1 โ€” Missing arguments, or database unknown. ๐Ÿ˜ญ
  3. 2 โ€” One or more supplied key could not be found in the database. ๐Ÿ™ˆ
  4. 3 โ€” Enumeration not supported on this database. ๐Ÿ’€

๐Ÿ‘€ SEE ALSO ๐Ÿ‘€


okay that's the whole page, you ate that, go forth and getent responsibly ๐Ÿซถ

mwah ๐Ÿ’‹ โ€” this was Linux man-pages 6.20, dated 2026-02-08, and it's the getent(1) page, section 1, no cap. ๐ŸŽ€โœจ

๐Ÿ“ฆ where this page comes from
  • arch rolling: man-pages 6.20-1 ยท BSD-2-Clause AND BSD-3-Clause AND BSD-4.3TAHOE AND BSD-4-Clause-UC AND GPL-1.0-or-later AND GPL-2.0-only AND GPL-2.0-or-later AND GPL-3.0-or-later AND LGPL-3.0-linking-exception AND LGPL-3.0-or-later AND LicenseRef-Public-Domain AND LicenseRef-UltraPermissive AND Linux-man-pages-1-para AND Linux-man-pages-copyleft AND Linux-man-pages-copyleft-2-para AND Linux-man-pages-copyleft-var AND MIT AND Spencer-94
  • nixpkgs unstable: man-pages 6.20
  • ๐Ÿ“œ the page's license: GPL-2.0-or-later
  • ๐Ÿ’– girlified by deepseek-ai/DeepSeek-V4.1-Flash on : a language model's rewrite of the original, under its terms