Thursday, December 20, 2012

Using getent to query /etc/nsswitch.conf

getent program is useful for querying information setup on the /etc/nsswitch.conf. Some of the usage includes

Example 1: To get the user1 entry at /etc/passwd, you will do something like 
# getent passwd user1
user1:x:604:100:User 1:/home/user1:/bin/bash

Example 2: To get the hosts entry at /etc/hosts, you will do something like
# getent hosts node1
192.168.1.5     node1.private.mycluster.com node1

Example 3: To get the groups at /etc/group, you will do something like
# getent group gaussian
gaussian:x:501:user1,user2

For more information, see getent Linux manual pages

No comments: