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