How to Find Out Which Group a User Belongs to in Ubuntu

In Ubuntu and other Linux distributions, file permissions and administrative rights are largely controlled by user groups. For example, if you want a standard user to be able to run commands with root privileges, they must be added to the sudo group. If they need to manage Docker containers, they need to be in the docker group.

Before adding a user to a new group, or when troubleshooting why a specific user is encountering “Permission Denied” errors, you need to check their current group memberships.

This guide explains two simple ways to find out exactly which groups a user belongs to in Ubuntu via the terminal.

Method 1: Using the ‘groups’ Command

The groups command is the most straightforward way to see group memberships. It outputs a simple, readable list of names.

  1. Open your Ubuntu terminal or SSH into your server.
  2. To see the groups for the user you are currently logged in as, simply type:
    groups
  3. Press Enter. The terminal will print a list like: johndoe sudo adm cdrom dip plugdev lxd
  4. If you want to check the groups for a different user, add their username to the end of the command. For example:
    groups janedoe
  5. Press Enter. The output will look like: janedoe : janedoe www-data

Method 2: Using the ‘id’ Command

While the groups command is easy to read, the id command provides more technical detail. It displays not only the group names but also their numerical Group IDs (GID) and the user’s numeric User ID (UID), which can be essential for scripting or advanced permissions auditing.

  1. In your terminal, type:
    id
  2. Press Enter. You will see output similar to this:
    uid=1000(johndoe) gid=1000(johndoe) groups=1000(johndoe),4(adm),24(cdrom),27(sudo),30(dip)

Just like the previous method, you can append a username to check someone else’s credentials:

id janedoe

Both commands safely query the system’s /etc/group file without requiring root (sudo) privileges, making them excellent, non-destructive tools for daily administration.

Get the best tech tips delivered straight to your inbox.

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