Chapter 4. User, Group and Permission

Getent (Display User and Group Data)

Getent (Display User and Group Data)
Tag:

The getent command is used to display entries from databases. There are multiple databases that Linux OS manages. For user-related data, there are two major databases – passwd for user data and group for group data. The command can also be used to show data from other databases.

Display User Data – getent passwd

To show the list of users, you can use the getent passwd command. This command gives you the same results as the ones you get when you retrieve data from the /etc/passwd file by running the grep or cat command.

To get all user data, simply run getent passwd without any argument. To get specific user data, add the user name or ID as the argument as shown below.

Command Line - INPUT
getent passwd user_a
Command Line - RESPONSE
user_a:x:2001:1003:comment for user_a:/home/normal_user/user_a:/bin/sh

Display User Data – getent group

To show a list of groups, you can use the getent group command. This command gives you the same results as the ones you get when you retrieve data from the /etc/group file by running the grep or cat command.

To get all user data, simply run getent group without any argument. To get specific user data, add the user name or ID as the argument as shown below.

Command Line - INPUT
getent group group_a
Command Line - RESPONSE
group_a:x:1003:user_a

The getent command is used to display entries from databases. There are multiple databases that Linux OS manages. For user-related data, there are two major databases – passwd for user data and group for group data. The command can also be used to show data from other databases.

Display User Data – getent passwd

To show the list of users, you can use the getent passwd command. This command gives you the same results as the ones you get when you retrieve data from the /etc/passwd file by running the grep or cat command.

To get all user data, simply run getent passwd without any argument. To get specific user data, add the user name or ID as the argument as shown below.

Command Line - INPUT
getent passwd user_a
Command Line - RESPONSE
user_a:x:2001:1003:comment for user_a:/home/normal_user/user_a:/bin/sh

Display User Data – getent group

To show a list of groups, you can use the getent group command. This command gives you the same results as the ones you get when you retrieve data from the /etc/group file by running the grep or cat command.

To get all user data, simply run getent group without any argument. To get specific user data, add the user name or ID as the argument as shown below.

Command Line - INPUT
getent group group_a
Command Line - RESPONSE
group_a:x:1003:user_a
Tag: