GETENT(1)

πŸ“¦ version 11.0, in nixpkgs unstable

✨ GETENT(1) β€” the getent girlies' era ✨

okay so this is the manual page for getent (and its twin getcap), from the General Commands Manual, and honestly bestie, it's lowkey a whole vibe. it's your lil cheat code for peeking inside the system's administrative databases. let's get into it πŸ’…


🌸 NAME 🌸

getent, getcap β€” get entries from administrative databases ✨ (yes that's the whole name section, she's short and iconic)


πŸŽ€ SYNOPSIS πŸŽ€

getent database [key ...]
getcap database [key ...]

like, that's it. two commands, one shape. slay.


πŸ¦‹ DESCRIPTION πŸ¦‹

okay so the getent program retrieves and displays entries from the administrative database specified by database, using the lookup order specified in nsswitch.conf(5). the display format for a given database is as per the "traditional" file format for that database. periodt. πŸ’–

database may be one of:

  • disktab β€” display format: entry
  • ethers β€” display format: address name
  • gettytab β€” display format: entry
  • group β€” display format: group:passwd:gid:[member[,member]...]
  • hosts β€” display format: address name [alias ...]
  • netgroup β€” display format: (host,user,domain) [...]
  • networks β€” display format: name network [alias ...]
  • passwd β€” display format: user:passwd:uid:gid:gecos:home_dir:shell
  • printcap β€” display format: entry
  • protocols β€” display format: name protocol [alias ...]
  • rpc β€” display format: name number [alias ...]
  • services β€” display format: name port/protocol [alias ...]
  • shells β€” display format: /path/to/shell

okay now the fun part 🫢 if one or more key arguments are provided, they will be looked up in database using the appropriate function. for example, passwd supports a numeric UID or user name; hosts supports an IPv4 address, IPv6 address, or host name; and services supports a service name, service name/protocol name, numeric port, or numeric port/protocol name. so like, she's flexible. she contains multitudes. 😭

if no key is provided and database supports enumeration, all entries for database will be retrieved using the appropriate enumeration function and printed. basically you get the whole roster, no filter, main character energy πŸ‘‘


and now the niche lore for the cgetcap(3) style databases (disktab, printcap) β€” ngl this part is giving special-case central 😀 specifying a key lists the entry for that key, and specifying more arguments after the key are used as fields in that key, and only the values of the keys are returned. for boolean keys true is returned if the key is found. if a key is not found, then false is always returned. no cap, that's literally the rule. πŸ’€


πŸ”₯ DIAGNOSTICS πŸ”₯

getent exits 0 on success, 1 if there was an error in the command syntax, 2 if one of the specified key names was not found in database, or 3 if there is no support for enumeration on database.

bestie memorize those numbers, they're the vibe check results: 0 slay, 1 you fumbled the syntax, 2 she's not in the database, 3 enumeration is just not her thing πŸ™ˆ

🌈 SEE ALSO 🌈

cgetcap(3), disktab(5), ethers(5), gettytab(5), group(5), hosts(5), networks(5), nsswitch.conf(5), passwd(5), printcap(5), protocols(5), rpc(5), services(5), shells(5)

(go read those too, iykyk 🧚)


⭐ HISTORY ⭐

a getent command appeared in NetBSD 3.0. it was based on the command of the same name in Solaris and Linux. so she's got lineage, she's got roots, she's a nepo baby of the Unix world and we love her for it πŸ’œ


and that's the whole manual, bestie β€” you ate that πŸ“

this page is from Debian, dated October 11, 2011 β€” yeah she's an older icon but she still serves πŸ’–βœ¨

πŸ“¦ where this page comes from