Polecenia Linuksa

How to Run 'groups' command in Linux

How to Run 'groups' command in Linux
In Linux, there is user and groups; users use the system, and groups are logical frameworks for managing a set of users. Users can be categorized into various groups, while groups are a set of multiple users.

It isn't easy to manage the privileges such as security and permission rights among different users. Group command makes it easy to manage them at a group level.

Give the username as input; it will return the member's name of primary and secondary groups. If no names are specified, it will print the currently running user information.

Syntax:

Syntax of “group” command would be like this:

$ group [option] [username]

How to use the “group” command:

Open the terminal, type “groups” to print the list of all groups that are currently logged in:

$ groups

Adding username as input:

Provide the username as an argument to get a list of all groups from which a particular user belongs, a username of my Linux device is “aqsa”:

$ groups aqsa

Getting User id:

Use the “id” command to display the information about a user and its groups. The command will show the primary and secondary groups; primary shows the user and group id while secondary shows the username:

$ id aqsa

Displaying usernames:

Use a combination of “-n” and “G” options to print usernames of all groups instead of user ids:

$ id -nG

Displaying group details:

Two ways to display the group's details:

  1. /etc/groups
  2. “getent” command

Use the below-mentioned command to get the list of all Linux groups:

$ cat /etc/group

The “getent” command shows entries from specified databases, which can be used to get a list of all groups:

$ getent group

To get the information of any particular group, pass “username” as an argument:

$ getnent group aqsa

If no output comes, it means the group does not exist.

$ getent group linux

Getting help information:

To print help information, type the “-help” command in a terminal. It gives a brief description and the related links of the “groups” command.

$ groups --help

Checking the version:

To check the version of the “groups” command in Linux, use the “version” command:

$ groups --version

Conclusion:

A “group” in Linux is a collection of users. The “groups” command lists all the groups and their details in the terminal. Groups make it simple to handle users who have similar security and access rights. We can also use the “/etc/group” and “getent” commands to display a list of groups. We have learned what the “groups” command is and the functionality of its different options.

Gry OpenTTD vs Simutrans
OpenTTD vs Simutrans
Creating your own transport simulation can be fun, relaxing and extremely enticing. That's why you need to make sure that you try out as many games as...
Gry OpenTTD Tutorial
OpenTTD Tutorial
OpenTTD is one of the most popular business simulation games out there. In this game, you need to create a wonderful transportation business. However,...
Gry SuperTuxKart for Linux
SuperTuxKart for Linux
SuperTuxKart is a great title designed to bring you the Mario Kart experience free of charge on your Linux system. It is pretty challenging and fun to...