getent stands for "get entries".
It is a Linux command that retrieves entries from system databases configured in NSS (Name Service Switch). Instead of reading only local files like /etc/passwd, it queries the system's configured user/group sources (local files, LDAP, NIS, Active Directory integration, etc.).
Syntax
Common examples
Get all users
Output:
Get a specific user
Output:
Get all groups
Get a specific group
Output:
Get host information
Output:
Why use getent passwd instead of cat /etc/passwd?
Only reads the local file.
Queries the system's user database, which may include:
- Local users (
/etc/passwd) - LDAP users
- Active Directory users
- NIS users
Therefore, getent is generally the recommended command for user lookups.
To list only usernames
Example output:
This is one of the most common commands to see all users known to an Ubuntu system.
No comments:
Post a Comment