Softpanorama

May the source be with you, but remember the KISS principle ;-)
Home Switchboard Unix Administration Red Hat TCP/IP Networks Neoliberalism Toxic Managers
(slightly skeptical) Educational society promoting "Back to basics" movement against IT overcomplexity and  bastardization of classic Unix

Solaris getent Command

As a system administrator, you can query name service information sources with tools, such as the ypcat, nslookup, niscat, and ldaplist commands.

You can use the ypcat command to query the NIS namespace. You can use the nslookup command to query the DNS namespace. However, when trying to isolate a problem, using one of these tools can return different results than standard system search operations, because the nsswitch.conf file is not referenced by these commands.

The getent command has these advantages:

Using the getent Command

The getent command retrieves a list of entries from the administrative database specified by database. The sources for the database are specified in the /etc/nsswitch.conf file. The syntax is:

getent database [key]...

where:

For the following examples, the /etc/nsswitch.conf file is configured to search files and then to search NIS.

# getent passwd lp

lp:x:71:8:LinePrinter Admin:/usr/spool/lp:

# getent group 10

staff::10:

# getent hosts sys44

192.168.30.44 sys44 loghost

The previous example assumes that the /etc/nsswitch.conf file is configured to search files and then to search NIS. If the /etc/nsswitch.conf file is configured to search NIS and then to search files, the output of the final search would be:

# getent hosts sys44
192.168.30.44 sys44

Notice the absence of loghost in this output. The loghost alias is a feature of the sys44 entry in the /etc/inet/hosts file but not the NIS map. Therefore, when the /etc/nsswitch.conf file search order is altered, the getent command looks up the entry in the NIS map before consulting the /etc/inet/hosts file.

Last modified: October 23, 2005