Ubuntu Linux: Find Groups A User Belongs To

How do I find out in which groups Ubuntu Linux users belong to? How do I find out Ubuntu Linux group membership for a particular user named tom?

You can use any one of the following command to list a groups a user belongs to:
Tutorial details
Difficulty Easy (rss)
Root privileges No
Requirements None
Time 1m

a) id command – Display real and effective user and group IDs.

b) groups command – Display the groups a user is in on Ubuntu Linux.

Ubuntu: See which groups your Linux user belongs to

Open the Terminal app or login to the remote server over the ssh based session. Type the following id command $ id -Gn

To display the groups a user named ‘tom’ is in on Ubuntu Linux, enter:
$ id -Gn tom

You can also use deprecated groups command as follows:
$ groups
$ groups tom

Sample outputs:

Fig. 01: groups and id command on Ubuntu

See also

🐧 Please support my work on Patreon or with a donation.
🐧 Get the latest tutorials on Linux, Open Source & DevOps via:
CategoryList of Unix and Linux commands
File Managementcat
FirewallAlpine Awall CentOS 8 OpenSUSE RHEL 8 Ubuntu 16.04 Ubuntu 18.04 Ubuntu 20.04
Network Utilitiesdig 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 jobs killall kill pidof pstree pwdx time
Searchinggrep 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
0 comments… add one

Leave a Reply

Your email address will not be published. Required fields are marked *

Use HTML <pre>...</pre> for code samples. Problem posting comment? Email me @ webmaster@cyberciti.biz