The Computer Oracle

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

--------------------------------------------------
Hire the world's top talent on demand or became one of them at Toptal: https://topt.al/25cXVn
--------------------------------------------------

Music by Eric Matyas
https://www.soundimage.org
Track title: Forest of Spells Looping

--

Chapters
00:00 How Do I List The Groups That A Unix User Is A Member Of?
01:11 Answer 1 Score 31
01:18 Answer 2 Score 119
01:35 Accepted Answer Score 7
01:49 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