getent

Query a namespace in a DNS name server

grammar

getent [option] hostname or domain name

Options

-h # Display help information
-n # Do not resolve DNS names
-p #Print the parsing process
-s # Only output information about known hosts
-t #Specify DNS query type (default is NXDOMAIN)
-U # Use top-level domain name server
-V # Display version information
-O #Resolve namespace in other modes

The hostname or domain name can be a wildcard (such as *.example.com) or a single hostname. If the -h option is specified, help information is displayed. If the -n option is specified, DNS names are no longer resolved. If the -p option is specified, the parsing process is printed. If the -s option is specified, only information about known hosts is output. If the -t option is specified, specifies the DNS query type (defaults to NXDOMAIN). If the -U option is specified, top-level domain name servers are used. If the -V option is specified, version information is displayed. If the -O option is specified, the namespace is resolved in other modes.

Example

getent passwd

This will list the password files for all known accounts, such as /etc/passwd or /run/user/1000/gshadow.

getent passwd someuser

This will only list the specified user's information, such as username, password, uid, gid, etc.

getenthostexample.com

This will list the DNS records for the example.com domain name, including the hostname, IP address, and other relevant information.

getententips8.ipaddress.com 80

This will list the TCP connection information for IP address 192.168.0.100, such as the connected server address, port number, and connection status.

getent port somehost.example.com

This will list the known ports for the specified host, such as port number, protocol, and hostname.

These are just some examples of the getent command, it has many other uses and options that can be adapted to your needs.