Linux command
getent 命令
文本
复制后可按需替换文件名、目录或参数。
常用示例
Example
getent group
Example
getent group [group_name]
Example
getent services
Example
getent passwd 1000
Example
getent hosts [host]
说明
getent queries entries from administrative databases configured in the Name Service Switch (NSS), including local files, LDAP, NIS, and other sources. It provides a unified interface to look up users, groups, hosts, and other system information regardless of where the data is stored. Unlike directly reading files like /etc/passwd, getent returns results from all configured NSS sources, making it essential for systems using centralized authentication (LDAP, Active Directory, etc.). Without a key, getent lists all entries in the database. With a key, it returns only matching entries.
参数
- passwd
- User account database (/etc/passwd and NSS sources)
- group
- Group database (/etc/group and NSS sources)
- hosts
- Hostname/IP resolution (like /etc/hosts, DNS)
- services
- Network services (/etc/services)
- protocols
- Network protocols (/etc/protocols)
- networks
- Network names and addresses
- shadow
- Shadow password entries (requires root)
- aliases
- Mail aliases
FAQ
What is the getent command used for?
getent queries entries from administrative databases configured in the Name Service Switch (NSS), including local files, LDAP, NIS, and other sources. It provides a unified interface to look up users, groups, hosts, and other system information regardless of where the data is stored. Unlike directly reading files like /etc/passwd, getent returns results from all configured NSS sources, making it essential for systems using centralized authentication (LDAP, Active Directory, etc.). Without a key, getent lists all entries in the database. With a key, it returns only matching entries.
How do I run a basic getent example?
Run `getent group` in a terminal, then adjust file names, paths, flags, or remote targets for your system.
What does passwd do in getent?
User account database (/etc/passwd and NSS sources)