How to List Groups in Linux

In Linux, every user is part of a collection known as a “group.” And for efficient system management, it is advised to regularly list and check all groups for the presence of any suspicious users. In this article, we will discuss the best methods to list all groups in your Linux system.

How to List All Groups from the Linux Terminal

Using the command line is the easiest way to list all groups in Linux, especially for beginners. Use either of the methods detailed below for the same:

1. Using groups Command

The simplest Linux command to list all groups is the groups command. Simply run the groups command, and you will get all groups in the output.

groups

2. Using the id Command

The id command is generally used to list group ids for the respective system groups. But it can be modified to show only the group names by adding options as follows:

id -G -n

In the above syntax, -G is used to print the group IDs, and -n is used to print the respective group names instead of the group IDs (-n option can only be used with -G, -g, and -u).

3. Using the cut Command

All information about the groups available in the system is stored inside the file “/etc/group.” To list all the Linux group names from the file, use the cut command as follows:

cut -d ':' -f 1 /etc/group 

This is what the syntax means in the above command:

  • the cut command is used to filter the sections of text in the file “/etc/group” based on some rules mentioned
  • -d ‘:’ is used to specify the delimiter as ‘:’
  • -f 1 is used to extract the 1st field which contains the group names
  • /etc/group specifies the file name to extract from

How to List All Linux System Groups (GUI Method)

Even though the CLI method to list all groups in your Linux system is the first choice for most users, some may prefer to use the graphical interface for the same. Here’s the GUI method to list all groups.

1. Open the Settings/ Command Center in your Linux distro.

2. Select “Users and Groups” from the “Administration” section.

3. This will open a new window named Users Settings. Click on “Manage Groups” here.

4. Scroll through the complete list of all groups to check the group names.

Comments 0
Leave a Reply