Linux commands-All users under a user group

Source: Internet
Author: User
Tags print print

Groups viewing the members of the currently logged on user group

Groups Gliethttp View the group that the Gliethttp user is in, and the members in the group
WHOAMI View the currently logged in user name

Information about groups within the system is placed in the/etc/group file, and the user's information is placed in the/etc/passwd file. Now I want to see all the users in a group named "Plants". First, you know the ID of the group, the GID. Use the command:

' Plants ' /etc/group
The result is: plants:x:1003 the GID is 1003 (this group 1003 on my computer, other computers may be other numbers). Then find the user in/etc/passwd that the group number is 1003. You can first use CAT/ETC/PASSWD to look at this file, found that the fourth column is GID (two columns between ":" separate). Next, enter:
Awk-f":"'{print $ ' \t\t ' $4}'1003' 

":" means ":" As the delimiter (/etc/passwd ":" As the delimiter), print print, and $4 for the first and fourth columns, and the user name and group number; \ t for tabs; grep ' 1003 ' indicates that the row containing 1003 is fetched.

In this way, all users within a group can be displayed.

Transferred from: http://www.2cto.com/os/201211/165118.html

Linux commands-All users under a user group

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.