View entries using the GETENT command in Linux

Home > Search > Linux commands
  by

The getent (get entries) command is similar to the cat command, in that it lets you view the contents of a file. However, the getent command is different from the cat command, in that it can query multipe sources. One of the most common uses of the getent command is when a system is configured with both local authentication and LDAP authentication. In this scenario, the local users will be listed in the /etc/passwd file, and the LDAP users will be on the LDAP server. The getent passwd command will display all of the local user accounts in /etc/passwd and all of the users on the LDAP server. In this example, Bush and Clinton are local user accounts, and Reagan and Clinton are users on the LDAP server.

~]# getent passwd
bush:x:1005:1006::/home/ford:/bin/bash
obama:x:1006:1007::/home/carter:/bin/bash
reagan:x:::::
clinton:x:::::

 

Likewise, if a system is configured with both local group accounts and LDAP group accounts, the getent group command will list both local groups and groups on the LDAP server.

~]# getent group
group1:x:1001:
group2:x:1002:
LDAPgroup:x::

 

Following are a list of common getent commands.

  • getent ahosts
  • getent ahostsv4
  • getent ahostsv6
  • getent aliases (email users)
  • getent ether (Ethernet)
  • getent group
  • getent gshadow (group passwords)
  • getent hosts
  • getent netgroup
  • gettet networks
  • getent passwd (user accounts)
  • getent protocol
  • getent rpc
  • getent services
  • getent shadow (user passwords)

 



Add a Comment




We will never share your name or email with anyone. Enter your email if you would like to be notified when we respond to your comment.




Please enter in the box below so that we can be sure you are a human.




Comments