How to List User Groups on Ubuntu Linux with examples

This brief tutorial shows students and new users how to list groups on Ubuntu 18.04 | 16.04 Linux systems.

If you’re a student or new user looking for a Linux system to start learning on, the easiest place to start is on Ubuntu Linux OS. It’s a great Linux operating system for beginners.

Ubuntu is an open-source Linux operating system that runs on desktops, laptops, servers, and other devices.

Both Ubuntu and Windows systems allow you to be productive, easy to use, and reliable and enable you to install and run thousands of programs from gaming to productivity suite software for individuals and businesses.

This post shows you how to perform the basic task of listing groups on Ubuntu Linux.

Linux Groups:

There are two types of groups users can be assigned to One is a primary and the other is a second group that grants privileges to users to access certain resources.

Below is how a typical Linux user account is added and assigned group memberships:

User A user who has an account must belong to one primary group. Typically, the user’s primary group is also named after the user account name.
Primary Group — The primary group is created at the same time the user account is created and the user is automatically added to it. The file created by the user automatically belongs to the user group.
Secondary Group — This group is not required and is only there to give users access to other resources they don’t already have access to. Users can belong to one or as many secondary groups are possible.

The primary user’s group is stored in the /etc/passwd file and the supplementary groups, if any, are listed in the /etc/group file.

List User Groups using the group’s command

Now that you know the types of groups for users, you can use the groups command to find the groups a user belongs to. Running the groups command without arguments will list all the groups the user belongs to.



Should output all the groups the account richard belongs to. The first group with the same name as the user account name is the primary group.

richard adm cdrom sudo dip plugdev lpadmin sambashare

To list all the groups a user belongs, add the username to the group’s command


groups richard

This should output the same as above

richard : richard adm cdrom sudo dip plugdev lpadmin sambashare

List User Groups using the id command

One can also use the id command to list group information about the specified user. It prints user and group information for the specified USER,

The command will show the username (uid), the user’s primary group (gid), and the user’s secondary groups (groups)

id richard

Should output the line below:

uid=1000(richard) gid=1000(richard) groups=1000(richard),4(adm),24(cdrom),27(sudo),30(dip),46(plugdev),116(lpadmin),126(sambashare)

List Group Membership using the getent command

If you want to know a particular group’s members, use the getent command. This command gets entries from the administrative database.

To get a membership of the cdrom group, run the command below

getent group cdrom

This should output all the users who have access to the cdrom group.

Listing All Groups

To list the entire groups on Ubuntu, run the command below

less /etc/group

That should output all the groups on each line


That’s it

Congratulations! You have learned how to list groups on Ubuntu Linux.