In CentOS, groups are used to manage user permissions and access to files and directories. It is important to know the groups to which a user belongs, especially when managing permissions on a multi-user system. In this guide, we will go through the steps to list user groups on CentOS using the “groups” command.
Step 1: Open the Terminal
The first step is to open the terminal on your CentOS machine. You can do this by clicking on the terminal icon or by using the keyboard shortcut “Ctrl + Alt + T”.
Step 2: List User Groups Using the “groups” Command
To list the groups to which a user belongs, you can use the “groups” command followed by the username. For example, to list the groups to which the user “john” belongs, you can use the following command:
groups john
This will display a list of groups to which the user “john” belongs.
Step 3: List All Groups on the System
To list all groups on the system, you can use the “getent” command followed by the “group” keyword. For example, to list all groups on the system, you can use the following command:
getent group
This will display a list of all groups on the system.
Commands Mentioned:
- groups – a command that lists the groups to which a user belongs.
- getent – a command that retrieves entries from the specified Name Service Switch (NSS) databases.
Conclusion:
In this guide, we have outlined the steps to list user groups on CentOS using the “groups” command. By using this command, you can easily obtain the necessary information about user groups on your system. If you have any questions or suggestions, feel free to comment below.