Get the App
SLTechnology News&Howtos  ›  Servers  › 

How does linux see which group a user belongs to

Shulou Source: shulou.com Published: 2022-05-31 23:06:24 09月13日 Update

This article mainly explains "how to check which group a user belongs to by linux". Friends who are interested may wish to take a look. The method introduced in this paper is simple, fast and practical. Let's let the editor take you to learn "how to check which group a user belongs to by linux".

View method: 1, directly execute the "groups" command, you can view the group to which the current user belongs; 2, execute the "groups user name" command, you can view the group to which the specified user belongs; 3, execute the "id user name" command, you can view the group to which the specified user belongs; 4, execute the "cat / etc/group" command and output group file information.

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

Linux's method to see which group the user belongs to:

Method 1: use groups directly to view the group to which the current user belongs

# groupsroot

Method 2: use the groups user name to view the group to which the specified user belongs

# groups xlyxly: xly

Method 3: use the id user name to view the group to which the specified user belongs

# id xlyuid=500 (xly) gid=500 (xly) groups=500 (xly)

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

# cat / etc/grouproot:x:0:bin:x:1:bin,daemondaemon:x:2:bin,daemonsys:x:3:bin,admadm:x:4:adm,daemontty:x:5:disk:x:6:lp:x:7:daemonmem:x:8:kmem:x:9:xly:x:500: at this point, I believe you have a better understanding of "how to check which group a user belongs to by linux". You might as well do it in practice. Here is the website, more related content can enter the relevant channels to inquire, follow us, continue to learn!

Tags: Users methods ownership commands user names content files learning practical deeper information interests practicality practical easy to operate tutorials more friends environment computer Apple Docker Huawei Linux macOS MariaDB Microsoft MySQL NVidia OPPO Reno Shulou Tech Info Docker NVidia Shulou Technology MariaDB