- Trending Categories
- Data Structure
- Operating System
- MS Excel
- C Programming
- Social Studies
- Fashion Studies
- Legal Studies
- Selected Reading
- UPSC IAS Exams Notes
- Developer's Best Practices
- Questions and Answers
- Effective Resume Writing
- HR Interview Questions
- Computer Glossary
- Who is Who
How to find what group a given user has on Linux?
We know that we can print all the users that are present on Linux with the help of the Linux utility command known as compgen.
The compgen command is a Linux utility command that is used to list all the commands that can be executed in a Linux terminal, and when used with a -u flag we can simply print all the users present on Linux.
Consider the command shown below as reference −
root daemon bin sys sync games man lp mail news uucp proxy www-data backup . . .
Now if we want to print the total groups that are present on our Linux operating system, we can either make use of the groups command.
The groups command is used to print all the groups that are present on the Linux kernel.
Usually the options in the above command are replaced by a particular user, for whom we want to check how many groups are present.
Let’s consider a few examples of the group's command.
sh-3.2# groups wheel daemon kmem sys tty operator procview procmod everyone staff certusers localaccounts admin com.apple.sharepoint.group.1 _appstore _lpadmin _lpoperator _developer _analyticsusers com.apple.access_ftp com.apple.access_screensharing com.apple.access_ssh com.apple.access_remote_ae
If you want to check groups of a particular user then run the below command.
sh-3.2# groups immukul staff everyone localaccounts _appserverusr admin _appserveradm _lpadmin com.apple.sharepoint.group.1 _appstore _lpoperator _developer _analyticsusers com.apple.access_ftp com.apple.access_screensharing com.apple.access_ssh com.apple.access_remote_ae
Kickstart Your Career
Get certified by completing the courseGet Started