How to check which group a user belongs to in Linux

青灯夜游
Release: 2021-11-30 16:55:48
Original
57835 people have browsed it

View method: 1. Directly execute the "groups" command to view the groups to which the current user belongs; 2. Execute the "groups username" command to view the groups to which the specified user belongs; 3. Execute "id username" command to view the groups to which the specified user belongs; 4. Execute the "cat /etc/group" command to output the group file information.

How to check which group a user belongs to in Linux

#The operating environment of this tutorial: linux5.9.8 system, Dell G3 computer.

Linux method to check which group a user belongs to:

Method 1: Usegroupsdirectly to view The group to which the current user belongs

# groups root
Copy after login

Method 2: Usegroups usernameto view the group to which the specified user belongs

# groups xly xly : xly
Copy after login

Method 3: Useid usernameto view the group to which the specified user belongs

# id xly uid=500(xly) gid=500(xly) groups=500(xly)
Copy after login

Method 4: Directly view the group file,cat /etc/group

# cat /etc/group root:x:0: bin:x:1:bin,daemon daemon:x:2:bin,daemon sys:x:3:bin,adm adm:x:4:adm,daemon tty:x:5: disk:x:6: lp:x:7:daemon mem:x:8: kmem:x:9: xly:x:500:
Copy after login

Related recommendations: "Linux Video Tutorial"

The above is the detailed content of How to check which group a user belongs to in Linux. For more information, please follow other related articles on the PHP Chinese website!

Related labels:
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template
About us Disclaimer Sitemap
php.cn:Public welfare online PHP training,Help PHP learners grow quickly!