How do I find out group membership for each user? How do I find out which users are in a group called sales?
The groups command display the groups a user is in. In this example, find out the group membership for user vivek, enter:
Adblock detected 😱
My website is made possible by displaying online advertisements to my visitors. I get it! Ads are annoying but they help keep this website running. It is hard to keep the site running and producing new content when so many people block ads. Please consider donating money to the nixCraft via
PayPal/
Bitcoin, or become a
supporter using Patreon.
groups userName
groups vivek |
groups userName
groups vivek
Sample outputs:
vivek : vivek adm dialout cdrom plugdev lpadmin netdev admin sambashare libvirtd
User vivek is member all of the above groups. Find out all users belongs to the group called adm:
grep -w groupName /etc/group
grep -w adm /etc/group |
grep -w groupName /etc/group
grep -w adm /etc/group
Sample outputs:
adm:x:4:vivek,top,jerry
See also:
Posted by: Vivek Gite
The author is the creator of nixCraft and a seasoned sysadmin, DevOps engineer, and a trainer for the Linux operating system/Unix shell scripting. Get the latest tutorials on SysAdmin, Linux/Unix and open source topics via RSS/XML feed or weekly email newsletter.