Linux Komutları

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.

AppyMouse On-screen Trackpad and Mouse Pointer for Windows Tablets
Tablet users often miss the mouse pointer, especially when they are habitual to using the laptops. The touchscreen Smartphones and tablets come with m...
Middle mouse button not working in Windows 10
The middle mouse button helps you scroll through long webpages and screens with a lot of data. If that stops, well you will end up using the keyboard ...
How to change Left & Right mouse buttons on Windows 10 PC
It's quite a norm that all computer mouse devices are ergonomically designed for right-handed users. But there are mouse devices available which are s...