How to find out what group a given user has?

强颜欢笑 提交于 2019-11-26 23:51:27

问题


In Unix/Linux, how do you find out what group a given user is in via command line?


回答1:


groups

or

groups user



回答2:


This one shows the user's uid as well as all the groups (with their gids) they belong to

id userid



回答3:


On Linux/OS X/Unix to display the groups to which you (or the optionally specified user) belong, use:

id -Gn [user]

which is equivalent to groups [user] utility which has been obsoleted on Unix.

On OS X/Unix, the command id -p [user] is suggested for normal interactive.

Explanation on the parameters:

-G, --groups - print all group IDs

-n, --name - print a name instead of a number, for -ugG

-p - Make the output human-readable.




回答4:


or just study /etc/groups (ok this does probably not work if it uses pam with ldap)



来源:https://stackoverflow.com/questions/350141/how-to-find-out-what-group-a-given-user-has

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!