The Computer Oracle

How do I list the groups that a UNIX user is a member of?

Become or hire the top 3% of the developers on Toptal https://topt.al/25cXVn

--

Music by Eric Matyas
https://www.soundimage.org
Track title: City Beneath the Waves Looping

--

Chapters
00:00 Question
01:29 Accepted answer (Score 6)
01:55 Answer 2 (Score 115)
02:17 Answer 3 (Score 30)
02:26 Thank you

--

Full question
https://superuser.com/questions/167965/h...

--

Content licensed under CC BY-SA
https://meta.stackexchange.com/help/lice...

--

Tags
#unix #permissions #useraccounts

#avk47



ANSWER 1

Score 119


You can also use the groups command:

[root@ftp ~]# groups root
root : root bin daemon sys adm disk wheel

if all else fails there is also good old grep:

[root@ftp ~]# grep root /etc/group
root:x:0:root
bin:x:1:root,bin,daemon
daemon:x:2:root,bin,daemon
sys:x:3:root,bin,adm
adm:x:4:root,adm,daemon
disk:x:6:root
wheel:x:10:root,admin



ANSWER 2

Score 31


$ id [username]



ACCEPTED ANSWER

Score 7


Found it - way later, but I did! =)

Just as

$>pts m [group name]

lists all the members in a group,

$>pts m [user name]

lists all the groups a user is member of. It was too simple :P