Linux view which users belong to which group/view user group

Source: Internet
Author: User

I. Discussion on the format of/etc/group

In the/etc/group format, many articles on the internet will say "group name: Group password: Group ID: Group User list", which is not a problem to understand the/etc/group format, but if you encounter the "View users belong to which group/view user group under which users" on the issue, Such a statement would be misleading.

Users in the group as a group are not included in the Test Discovery group List of users. This leads to the following problems:

When working with "see which groups a user belongs to", if you use grep username/etc/group directly, you can only find the additional group to which the user belongs instead of the most important group of main genera

If you are working directly with grep Groupname/etc/group when dealing with users who are under the View user group, you can only find users with that group as additional groups instead of the most important users who are the primary group

Second, see which groups the user belongs to

2.1 Using Groups to view

To see which groups Oracle users belong to, for example:

2.2 Combining/etc/passwd and/etc/group view

To see which groups Oracle users belong to, for example:

grep 'grep oracle/etc/passwdcut':"4'/etc /group  cut":"1  #查看用户所属主属组 grep Cut " : " 1 #查看用户所有所属附加组

That is, Oracle belongs to the Oinstall group and the DBA group, where Oinstall is the primary group and the DBA is the additional group.

Third, see which users are under the user group

To see which users are under the Oinstall group as an example

grep 'grepcut':'3 '/etc/passwd  | Cut-d ":"-F # View user grepcut":"in its primary group4 # View users with additional groups

That is, there are oracle,test,test2 three users under the Ointall group, where Oracle is a oinstall group, and test and test2 Oinstall as additional groups.

Linux view which users belong to which group/view user group

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.