Linux Groupmems commands

Source: Internet
Author: User

Because Users group membership is defined in the different locations, it can be difficult to find out which groups exactly A user is a member of. A Convenient command to check that is groupmems . Use, for example, the command groupmems-g sales-l to see which users is a member of the group sales. This shows users who is a member of this group as a secondary group assignment, but also the users who is a member of this G Roup as the primary group assignment.

[Email protected] ~]# Groupmems--helpusage:groupmems [Options] [action]options:-G,--group groupname change groupname instead of the user'S Group(Root only)-R,--root Chroot_dir directory to CHROOT intoactions:-A,--Add username add username to the members of the group-D,--delete username remove username fromThe members of the group-H,--help display ThisHelp message and exit-P,--purge purge all members fromThe group-L,--list list the members of the group

Cases:

See which users belong to the sales group

[Email protected] ~]# groupmems-g sales-Llinda Lisa

Remove Lisa from the sales group

[Email protected] ~]# groupmems-d lisa-G sales  ~]# groupmems-g Sales-

Add user to Group

[[Email protected] ~]# ID lxj2uid=1002(lxj2) gid=0(root) groups=0~]# Groupmems-a lxj2-~]# id lxj2uid=1002(lxj2) gid=0(root) groups=0(Root), 1238 (sales)

You can also use the Usermod command to add users to a group

Usermod-ag would add users to new groups that would be used as their secondary group.

Use Usermod to add users Linda and Lisa to the group sales, and Lori and Bob to the group account:

Usermod-AGSales Linda  -AGsales Lisa  -AG account Lori  

Linux Groupmems commands

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.