List All The Groups In Linux

4 min read

Linux groups are the backbone of multi-user permission management, and knowing how to list all the groups in Linux is a core skill for administrators, developers, and anyone troubleshooting access issues. Groups let you assign permissions to multiple users at once, simplifying security and collaboration. Whether you need a quick inventory of every group on a system, want to see which groups a specific user belongs to, or need to filter system groups from regular user groups, Linux offers several reliable commands. This guide walks through the most practical methods, explains how to read their output, and answers common questions so you can manage groups with confidence Most people skip this — try not to. Turns out it matters..

Understanding Linux Groups Before You List Them

A Linux group is a collection of user accounts that share a common set of permissions. Every file and directory has an owner, a group, and permissions for others. When a user belongs to a group, they inherit that group’s access rights. Plus, each group has a group name, a group ID (GID), and an optional list of members. The system stores this information in the /etc/group file, while /etc/gshadow holds secure group password data And it works..

Not the most exciting part, but easily the most useful Worth keeping that in mind..

There are two main types of groups:

  • Primary group: Assigned to a user in /etc/passwd. New files created by the user typically inherit this group.
  • Secondary (supplementary) group: Additional groups a user belongs to, granting extra permissions without changing their primary group.

Linux also distinguishes between system groups and regular user groups. System groups often have GIDs below 1000 and support services such as sudo, docker, or systemd-journal. Worth adding: regular groups usually start at GID 1000 or higher, depending on the distribution. Understanding this distinction helps you interpret the output when you list all groups Surprisingly effective..

How to List All Groups in Linux

You can list all groups in Linux using several commands. Each method has strengths, so choose the one that fits your workflow.

1. Use getent group for a Clean, System-Wide List

The getent command queries the system’s group database, including local files and network services such as LDAP or NIS. To list all groups, run:

getent group

This prints every group in the format:

group_name:password:GID:member1,member2

For example:

sudo:x:27:alice,bob
developers:x:1001:carol,dan

getent group is often the best choice because it respects the system’s name service switch configuration. If your machine uses centralized authentication, this command shows groups from all configured sources, not just /etc/group.

To list only group names, combine it with cut:

getent group | cut -d: -f1

2. Read /etc/group Directly

The /etc/group file contains local group definitions. You can display it with:

cat /etc/group

Or page through it:

less /etc/group

Each line has four colon-separated fields:

  1. Group name
  2. Password placeholder (usually x)
  3. GID
  4. Comma-separated member list

Reading /etc/group is fast and works on nearly every Linux system. Still, it only shows local groups. If your environment relies on LDAP, SSSD, or other directory services, use getent group instead But it adds up..

3. Use compgen -g to List Group Names Only

Bash’s compgen builtin can list group names without extra formatting:

compgen -g

This prints one group name per line. It is handy for scripts or quick checks. Note that compgen -g relies on the shell’s completion system and may not include groups from remote directory services in every configuration.

4. Extract Group Names with cut

If you want a clean list of group names from /etc/group, use:

cut -d: -f1 /etc/group

To sort the output alphabetically:

cut -d: -f1 /etc/group | sort

To count how many groups exist:

cut -d: -f1 /etc/group | wc -l

These one-liners are useful for audits, reports, and comparing group lists across systems.

5. List Groups for a Specific User

Sometimes you do not need every group on the system—you need the groups a particular user belongs to. Use:

groups username

Or:

id username

The id command shows the user’s UID, primary GID, and supplementary groups. For example:

id alice

Output:

uid=1001(alice) gid=1001(alice) groups=1001(alice),27(sudo),1002(developers)

To list only the group names for a user:

groups username | tr ' ' '\n'

We're talking about especially helpful when debugging permission errors or verifying that a user has been added to the correct secondary groups Nothing fancy..

Interpreting the Output When You List All Groups

When you run getent group or cat /etc/group, each line follows this pattern:

group_name:password:GID:members
  • Group name: The human-readable identifier.
  • Password: Usually x, meaning the password is stored in /etc/gshadow. An empty field may indicate no password.
  • GID: The numeric group ID. Lower numbers often belong to system groups.
  • Members: A comma-separated list of users who are secondary members. The
Hot and New

Current Topics

You'll Probably Like These

Others Also Checked Out

Thank you for reading about List All The Groups In Linux. We hope the information has been useful. Feel free to contact us if you have any questions. See you next time — don't forget to bookmark!
⌂ Back to Home