Each version of the Linux operating system controls hardware resources, starts and manages programs, and provides a user interface in some form. There is an accessible version of Linux for virtually every job due to the large development community and variety of distributions, and Linux has permeated many fields of computing. A group is a collection of users in Linux. The primary use of groups is to specify a set of permissions, such as read, write, or execute permission for a given resource, that can be shared by group members. To take advantage of the rights that an existing group provides, users can be added to it. We have mentioned below the step to list all users in a Linux group.
Steps to List All Users in a Linux Group
List members of a group on Linux using the /etc/group file
Step 1: Group information is contained in the file /etc/group🇧🇷 You can view the contents of this file and search for member information. Typically, this file has input in the following format: Step 2: If you find it difficult to manually search for a group in the archive, you can use a combination of the grep command and the cut command🇧🇷 Step 3: The above command searches for all lines that start with the specified group name, then the cut command extracts the fourth column separated by: delimiter. The result is just the name of the group members.
List group members on Linux with getent command
Step 1: getent is a multipurpose command used to query database files on the /etc directory🇧🇷 Then you can use it to query the /etc/group file and get the users of the specified group as follows: Step 2: This will display the line corresponding to the name of the group and here you can see the group members:
List users in a group using the ‘members’ command
There is a small command line tool that simplifies the process of listing all members of a specific group. Step 1: The members command is usually not installed on all systems, so you must install on its own. Step 2: On Debian/Ubuntu based systems, you can install it using the following command: Step 3: If the command is not found in Ubuntu you should enable universe repository and try again. Step 4: After installing the command, you can run so:
Final Words
We hope you enjoy our article on how to List all users in a group on Linux. Currently, it is used as a platform to operate desktops, servers and embedded systems, therefore, it is not restricted to the operating system alone. Being open source and having a modular design, it offers a variety of distributions and customizations. A crucial component of the Linux system is the kernel. The Linux operating system is used to manage various services, including file system management, basic peripheral device management, process scheduling, and application scheduling.