commands
getent — query NSS databases
Queries configured database sources, not necessarily local files. GNU -s selects a service; passwd with a key retrieves matching account data. Exit 2 means one or more requested keys were not found. Use targeted, non-sensitive lookups. Example assumes a fresh account lab fixture; VM-only examples require explicit authorization.
Formal Syntax & Structure
linux syntaxlinux
getent [OPTION] DATABASE [KEY...]Parameters & Attributes
| Name | Type | Description |
|---|---|---|
| -s | option | select NSS service |
| DATABASE | operand | database name |
| KEY | operand | optional lookup key |
Return Value
exit status and output
Queries configured database sources, not necessarily local files. GNU -s selects a service; passwd with a key retrieves matching account data. Exit 2 means one or more requested keys were not found. Use targeted, non-sensitive lookups.
Working Example
Example Snippetlinux
getent -s files passwd root | awk -F: '{print $1, $3}'