Linux/UNIX: Find Which Groups Do I Belong To

How do I find out in which groups do I belong to on Linux or Unix-like operating systems? How can I find out my group membership so that I can determine access to devices and files on Linux/Unix operating systems?

A user can be in any number of groups apart from his/her default group. Groups are created and managed by root user. You cannot edit or modify your own ownership. However Linux allows you to view in which groups you are by using the groups command. This is useful to find out if you can access:
Tutorial details
Difficulty level Easy
Root privileges No
Requirements None
Est. reading time 1m
  1. Directories
  2. Files
  3. Devices
  4. Burn CD/DVD
  5. Backup files
  6. Restart system services
  7. Play music and video and more.

Task: Display or print the groups a user is in

Type the whoami command to display your user ID:
$ whoami
Sample outputs:


See which groups your Linux/Unix user belongs to

Type the groups command to show which groups your Unix or Linux user belongs to:
$ groups
Sample outputs:

vivek dialout cdrom floppy audio video plugdev

So my default group is vivek and I am a member of dialout, cdrom, floppy, audio, video plugdev group. You can also use id command to print both numeric and name based group id:
$ id

uid=1000(vivek) gid=1000(vivek) groups=20(dialout), 24(cdrom), 25(floppy), 29(audio), 44(video), 46(plugdev), 1000(vivek)

The id command is preferred command to list groups a user belongs to On Linux or Unix-like operating systems:
$ groups
$ groups userNameHere
$ id -Gn
$ id -Gn userNameHere

Sample outputs:

Animated gif 01: groups and id command to display groups a user belongs to

See also

🐧 Get the latest tutorials on Linux, Open Source & DevOps via RSS feed or Weekly email newsletter.

🐧 1 comment so far... add one

CategoryList of Unix and Linux commands
Disk space analyzersdf duf ncdu pydf
File Managementcat cp mkdir tree
FirewallAlpine Awall CentOS 8 OpenSUSE RHEL 8 Ubuntu 16.04 Ubuntu 18.04 Ubuntu 20.04
Modern utilitiesbat exa
Network UtilitiesNetHogs dig host ip nmap
OpenVPNCentOS 7 CentOS 8 Debian 10 Debian 8/9 Ubuntu 18.04 Ubuntu 20.04
Package Managerapk apt
Processes Managementbg chroot cron disown fg glances gtop jobs killall kill pidof pstree pwdx time vtop
Searchingag grep whereis which
User Informationgroups id lastcomm last lid/libuser-lid logname members users whoami who w
WireGuard VPNAlpine CentOS 8 Debian 10 Firewall Ubuntu 20.04
1 comment… add one
  • saeed Mar 15, 2013 @ 7:31

    I am saeed from Iran I wanna ask you a question:
    if a person haven,t access to can I join these groups?

Leave a Reply

Your email address will not be published.

Use HTML <pre>...</pre> for code samples. Still have questions? Post it on our forum