How to List  Groups on Debian 12

Groups are used to manage the users and define their specific tasks. Using the groups in Debian 12, different tasks and privileges to the directories can be assigned to the group of users. 

There are some system groups including the root(0), tty(5), and sudo (27) used for granting the complete system control, terminal control, and super user control respectively. The users added to these groups will enjoy the mentioned control on Debian 12. 

Groups in Debian including the user-created groups and the system-defined groups, can be listed down on Debian 12. The methods of listing down the groups on Debian 12 are explained in this post with the following outline:

  1. Why is it Important to List Down the Groups on Debian 12
  2. What are the Methods to List Down the Groups on Debian 12
  3. Method 1: List Groups on Debian 12 Using the getent Command
  4. Method 2: List Groups on Debian 12 Using the /etc/group File
  5. Method 3: List Groups on Debian 12 Using the id Command
  6. Method 4: List Groups on Debian 12 Using the libuser Command
  7. Method 5: List Groups on Debian 12 Using the groups Command
  8. How to Manage Users to a Group in Debian 12

Let’s find out all these methods after exploring the reasons behind the listing of the groups on Debian 12. 

Why is it Important to List Down the Groups on Debian 12?

The reasons for listing down the groups on Debian 12 are explained below:

  • Groups are listed down to manage the assigned roles to different users
  • It is also used to monitor the duties and roles of the users 
  • It is also used to manage the users in the groups
  • To monitor the unusual addition of the groups can also be ensured by listing down the groups on Debian 12
  • To find the groups associated with the specific users can also be done after listing down the groups

What are the Methods to List Down the Groups on Debian 12?

Both the command line and GUI-based methods are used for displaying the list of the groups on Debian 12. With the runtime demonstration, all the methods are explained one by one in the below-mentioned sections. 

Method 1: List Groups on Debian 12 Using the getent Command

The getent command displays the list of different entries of Debian 12. It has access to all databases of the computer. 

To display the groups on Debian 12 using the getent command, execute the command:

$ sudo getent group

All the groups are displayed on the screen by extracting the information from various databases of Debian 12. To sort the groups in their alphabetical order, use the sort command with the grep command:

$ sudo getent group | sort

The group names are displayed by sorting them alphabetically. To display the groups having the “admin” files, run the command:

$ sudo getent group | grep admin

Method 2: List Groups on Debian 12 Using the /etc/group File

The /etc/group is the file containing the information of the groups in Debian 12. The information in the file is available in the below-mentioned format:

group_name:password:GID:user_list

To display the output of the Groups on Debian 12 using the /etc/group file, run the cat command to display the contents:

$ cat /etc/group

In the output, the group names can be seen available on Debian 12. We can also use the cut command to extract the names of the groups by extracting the specific column with the following command:

$ cut -d: -f1,6 /etc/passwd

The names of the groups have been displayed on the screen. 

Method 3: List Groups on Debian 12 Using the id Command

The id command can also be used to list down the groups as primary usage of the id command is to display names of the groups and their GIDs. To display the groups associated with the current user, run the “id” command without using its options:

$ id

It can be seen that the group IDs have been displayed associated with the current user. To display the names of the groups instead of their IDs, run the command:

$ sudo id -ng itslinuxfoss

The group names are displayed associated with the “itslinuxfoss” user. 

Method 4: List Groups on Debian 12 Using the libuser-lid Command

Another command that can display the groups on Debian 12 is the libuser-lid command utility. To use the libuser-lid command, first, install it with the execution of the following command:

$ sudo apt install libuser -y

When the command utility is installed, use it to display the groups associated with the current user or some specific user:

$ sudo libuser-lid

The output will show the details of the current user only. If the information of any other user is supposed to display then run the command:

$ sudo libuser-lid itslinuxfoss

The output displays the group names associated with the “itslinuxfoss” user on Debian 12. 

Method 5: List Groups on Debian 12 Using the groups Command

The group command is also used to find out the information of the groups associated with the specified user. For example, display all the associated groups with the “itslinuxfoss” user by running the mentioned below command:

$ sudo groups itslinuxfoss

To display the information of the groups related to the current user, execute the command:

$ sudo groups

All the groups of the current user have been displayed on the screen.

How Users to a Group can be Manage in Debian 12?

To add and remove the users to different groups on Debian 12, it is recommended to go through the mentioned below blog:

Following the instructions explained in the blog, users will be able to manage the users in the groups of Debian 12. 

All these five methods can be used to display the information of the groups on Debian 12. 

Conclusion

To list the groups on Debian 12, different command line utilities can be used. These include the getent, groups, libuser-lid,and id commands. The groups are listed down on the Debian 12 to manage the users and their roles. All the explained methods for listing groups on Debian 12 have been displayed in this post.

Join 10 Select Businesses Growing with Us! 500M+ Views Across Our Blogs & YouTube Channels – Be Part of Our Success. Click here to learn more. Click here if you are interested. ×