How to Check User Group Memberships Using the groups Command in Linux

When you are managing users and configuring file permissions on a multi-user Linux server, understanding group memberships is critical. If a developer complains that they cannot access a shared project directory, it is almost always because their user account has not been added to the correct secondary group. To instantly view exactly which groups a specific user belongs to, you should use the groups command.

How the groups Command Works

In Linux, every user account is assigned to a “primary” group upon creation (usually sharing the same name as the username). However, users can also be added to multiple “secondary” or “supplementary” groups, which grant them specialized access to things like the sudo wheel (for administrative privileges) or the docker group (to run containers without root access).

The groups command queries the system’s identity files (primarily /etc/group) and prints out a simple, space-separated list of all the groups associated with a username.

Checking Your Own Group Memberships

To see which groups your current logged-in user account belongs to, simply type the command into the terminal without any arguments and press Enter.

groups

The output will simply list the group names. For example, if you are a standard administrative user on an Ubuntu server, the output might look like this:

john sudo adm cdrom plugdev lxd

In this example, the user belongs to their primary group (john), but also belongs to several critical secondary groups, including sudo, which confirms they have administrative access.

Checking Another User’s Memberships

If you are the system administrator and need to troubleshoot permissions for a different employee, you do not need to log in as them. You can check their group memberships by providing their username as an argument.

groups ssmith

The command will format the output slightly differently, prefixing the list with the username to avoid confusion:

ssmith : ssmith developers webadmins

This output clearly confirms that the user ssmith is a member of the developers and webadmins groups, meaning they will inherit any file permissions granted to those specific groups across the entire filesystem.

Get the best tech tips delivered straight to your inbox.

Join thousands of readers mastering Apple, Google, Microsoft, and Linux.