In linux, there can be multiple users(those who use/operate the system), and groups are nothing but the collection of users. Groups make it easy to manage users with the same security and access privileges. A user can be part of different groups.
- Groups command prints the names of the primary and any supplementary groups for each given username, or the current process if no names are given.
- If more than one name is given, the name of each user is printed before the list of that user’s groups and the username is separated from the group list by a colon.
Example 1: Provided with a user name
In this example, username demon is passed with groups command and the output shows the groups in which the user demon is present, separated by a colon.
Example 2: No username is passed then this will display group membership for the current user
Here the current user is demon . So when we give “groups” command only we get groups in which demon is a user.
Example 3: Passing root with groups command
Note: Primary and supplementary groups for a process are normally inherited from its parent and are usually unchanged since login. This means that if you change the group database after logging in, groups will not reflect your changes within your existing login session. The only options are –help and –version.
- rm command in Linux with examples
- less command in Linux with Examples
- dc command in Linux with examples
- gdb command in Linux with examples
- arp command in Linux with examples
- gs command in Linux with Examples
- fc Command in Linux with Examples
- ZIP command in Linux with examples
- help Command in Linux with examples
- rcp Command in Linux with examples
- cc command in Linux with Examples
- atd command in Linux with examples
- if command in linux with examples
- apt command in linux with examples
- atq command in linux with examples
If you like GeeksforGeeks and would like to contribute, you can also write an article using contribute.geeksforgeeks.org or mail your article to email@example.com. See your article appearing on the GeeksforGeeks main page and help other Geeks.
Please Improve this article if you find anything incorrect by clicking on the "Improve Article" button below.