All users:

$ getent passwd

All groups:

$ getent group

All groups with a specific user:

$ getent group | grep username
Answer from EEAA on serverfault.com
๐ŸŒ
GeeksforGeeks
geeksforgeeks.org โ€บ linux-unix โ€บ groups-command-in-linux-with-examples
Groups Command in Linux - GeeksforGeeks
May 12, 2026 - The groups command in Linux is used to display the group memberships of a user. It shows the primary group and all supplementary groups associated with a user account.
๐ŸŒ
Linux Man Pages
man7.org โ€บ linux โ€บ man-pages โ€บ man1 โ€บ groups.1.html
groups(1) - Linux manual page
GROUPS(1) User Commands GROUPS(1) groups - print the groups a user is in ยท groups [OPTION]... [USERNAME]... Print group memberships for each USERNAME or, if no USERNAME is specified, for the current process (which may differ if the groups database has changed).
People also ask

What is an example of chmod?
The chmod command in Linux changes file permissions. Here's a simple example: This gives the owner full control and lets others read and run the file. It's often used for web server files to balance access and security.
๐ŸŒ
daily.dev
daily.dev โ€บ home โ€บ blog โ€บ insights โ€บ linux user groups and permissions guide
Linux User Groups and Permissions Guide | daily.dev
What is chmod 777 file permissions example?
chmod 777 gives everyone full access to a file or directory. For example: This opens up the "public\_files" directory to everyone. But be careful - it's risky. While sometimes needed, it's usually not a good idea. Instead, try more limited permissions like 755 for directories or 644 for files. These keep things safer while still letting people do what they need to do.
๐ŸŒ
daily.dev
daily.dev โ€บ home โ€บ blog โ€บ insights โ€บ linux user groups and permissions guide
Linux User Groups and Permissions Guide | daily.dev
๐ŸŒ
Server Academy
serveracademy.com โ€บ blog โ€บ linux-list-groups
How to List Linux Groups - Blog - ServerAcademy.com
Introduction to Linux Groups Linux Groups are a fundamental part of managing permissions and organizing users. They're not just a feature for advanced users, bu
๐ŸŒ
ArchWiki
wiki.archlinux.org โ€บ title โ€บ Users_and_groups
Users and groups - ArchWiki
May 3, 2026 - A simple tool, such as cat, designed ... and playback can be done simply with the commands, "cat /dev/audio > myfile" and "cat myfile > /dev/audio," respectively. Every file on a GNU/Linux system is owned by a user and a group....
๐ŸŒ
daily.dev
daily.dev โ€บ home โ€บ blog โ€บ insights โ€บ linux user groups and permissions guide
Linux User Groups and Permissions Guide | daily.dev
November 8, 2024 - Linux automatically makes a primary group also called "bob". You can check this in the /etc/passwd file: ... This command shows bob's User ID (UID) and Group ID (GID), confirming his main group.
Find elsewhere
๐ŸŒ
Jvns.ca
jvns.ca โ€บ blog โ€บ 2017 โ€บ 11 โ€บ 20 โ€บ groups
How do groups work on Linux?
November 20, 2017 - When a process tries to read a file owned by a group, Linux a) checks if the user julia can access the file, and b) checks which groups julia belongs to, and whether any of those groups owns & can access that file
๐ŸŒ
Baeldung
baeldung.com โ€บ home โ€บ administration โ€บ user administration โ€บ list all groups in linux
List All Groups in Linux | Baeldung on Linux
March 18, 2024 - We can combine the -G and -n options to make the id command print all group names of a given user. Similar to the groups command, if we donโ€™t tell id a username, itโ€™ll print group names of the current user:
๐ŸŒ
IBM
ibm.com โ€บ docs โ€บ SSFKSJ_9.2.0 โ€บ com.ibm.mq.sec.doc โ€บ q011110_.html
Creating and managing groups on Linux - IBM Documentation
On Linux, group information is held in the /etc/group file. You can use commands to create a group, add a user to a group, display a list of the users who are in the group, and remove a user from a group.
๐ŸŒ
Linux Journal
linuxjournal.com โ€บ content โ€บ how-list-groups-linux-pro
How to List Groups in Linux Like a Pro | Linux Journal
Outputs a space-separated list of groups that john belongs to. If no username is given, it shows groups for the current user. id username ... This command provides detailed user identity information, including UID, GID, and all group memberships:
๐ŸŒ
IBM
ibm.com โ€บ docs โ€บ en โ€บ ibm-mq โ€บ 9.3.x
Creating and managing groups on Linux
On Linux, providing you are not using NIS or NIS+, use the /etc/group file to work with groups.
๐ŸŒ
KodeKloud
kodekloud.com โ€บ blog โ€บ how-to-list-all-groups-in-linux
How to List All Groups in Linux
November 5, 2025 - Check user-specific groups using the groups, id, and lid commands. See creative uses of awk, sort, and tr to extract unique GIDs and group names. Understand GUI options for group management in Linux distributions.
๐ŸŒ
Pluralsight
pluralsight.com โ€บ blog โ€บ software development
How to Add Users to a Group in Linux | Pluralsight
March 7, 2025 - Commands like useradd, usermod, and groupadd are fundamental Linux user management commands. Whether you're learning how to add a user to a group in Linux or using groupadd to set up new user roles, these tools give you direct control over access ...
๐ŸŒ
nixCraft
cyberciti.biz โ€บ nixcraft โ€บ howto โ€บ linux โ€บ how to find out which groups a user belongs to in linux
Linux Show The Groups a User Is In - nixCraft
April 3, 2024 - How do I find out what groups I belong to under Linux operating systems? How do I display the groups a Linux user belongs to? The /etc/group is a text file which defines the groups on the Linux system. You can use the groups command to display group memberships for any user using the following syntax.
๐ŸŒ
StrongDM
strongdm.com โ€บ blog โ€บ security
How to List All Groups in Linux: Complete Command Guide
April 21, 2025 - One of the most common and straightforward ways to list all groups in Linux systems is by leveraging the Linux "list groups" command. However, this isnโ€™t the only way. There are several alternative methods, such as the "getent" command, the ...
Top answer
1 of 4
10

In response to the comment by @Chris that

This only works for groups without spaces in the names!

I should mention that the accepted solution by @c4f4t0r and the solution by @bibi will work in most cases. I am running Cygwin, and the Windows part of the equation is probably why I hit this problem more often. Still, a group could be made with non-standard characters in normal Linux (I think), so I'll give the solution for group names with spaces. Spaces always make life fun!

I'll quickly give an example where spaces cause a problem. To see the group names with spaces, we look at the entire output of id

Copy$ id
uid=1(me) gid=545(Users) 
groups=545(Users),66049(CONSOLE LOGON),11(Authenticated Users),
4095(CurrentSession),66048(LOCAL)

(Note: I did make the output a little more pleasing to the eye here on StackOverflow.)

From this, we see that the groups are {'Users', 'CONSOLE LOGON', 'Authenticated Users', 'CurrentSession', 'LOCAL'}

We can see the problem with the accepted solution in this case.

Copy$ echo "groups:" ; for i in $(id -Gn);do echo "  - $i" ;done
    groups:
      - Users
      - CONSOLE
      - LOGON
      - Authenticated
      - Users
      - CurrentSession
      - LOCAL

A couple of groups get their names split up. To get the output we want, we need to use the id command, which takes a --zero ( -z ) flag. For more details on all the flags passed to id, see here.

Copy$ man id | grep -A 1 "\-\-zero"
       -z, --zero
              delimit entries with NUL characters, not whitespace;

Our approach will need to be a bit different to those given above, but follow a lot of the same principles:

Copy$ echo "groups:"; printf "%s" "  - "; id -Gnz | \
awk 'BEGIN{FS="\0"; OFS="\n  - "}{NF--; print}'
groups:
  - Users
  - CONSOLE LOGON
  - Authenticated Users
  - CurrentSession
  - LOCAL

The reason that we have a slightly-more-complicated awk is that there is always a trailing NUL, which we do not want in this case. The \ allows me to continue onto the next line with the same command, making things easier to read. The command is equivalent to:

Copy$ echo "groups:"; printf "%s" "  - "; id -Gnz | awk 'BEGIN{FS="\0"; OFS="\n  - "}{NF--; print}'
2 of 4
6

How about this for a succinct solution that deals with spaces:

Copyid -Gnz | tr "\0" "\n"
๐ŸŒ
PhoenixNAP
phoenixnap.com โ€บ home โ€บ kb โ€บ sysadmin โ€บ how to add user to group in linux
How to Add User to Group in Linux
December 10, 2025 - The following steps explain how to add a user to one or multiple groups in Linux. 1. Use the adduser command to add a user to a group:
๐ŸŒ
RunCloud
runcloud.io โ€บ blog โ€บ linux-users-groups-ubuntu
How to List Linux Users and Groups in Ubuntu with Command Line
May 22, 2024 - RunCloud simplifies the process, ... effortless. Sign up for RunCloud today! To create a group, use the groupadd command followed by the name of the group....