Linux Account Management Chapter II: Management of user groups

Source: Internet
Author: User

1. Viewing the user's effective group

    Groups user Name

Note: There may be multiple results from the view; The first is the primary group, followed by the sub-group

  

2. Adding and removing groups

Adding a group: Groupadd Group name

Delete a group: Groupdel Group name  

To add a user to a group: GPASSWD-A user 1

Create a Bob group Groupadd Bob

Add user 1 to the Bob Group gpasswd-a user 1 Bob

Parameters:-A add

-D Delete

-a set a user as the administrator of the group

For example1:(add user to a group)

[[email protected] sorry]# groupadd BOB  //Create a group [[email protected] sorry]# groups sorry  //See what Likui belongs to Group Sorry:sorry[[email protected] sorry]# gpasswd-a sorry Bob        //Add Likui to Bob Group      

For example2: ( set a user as the administrator of a group )

[[email protected] sorry]# useradd Tom                 //Create a Tom user [[email protected] sorry]# ll/home/total4drwx------. Orry Sorry   4096 June 20:14 likuidrwx------.  3 Tom   Tom   June 20:27 Tom[[email protected] sorry]# groupadd Bob           //Create a Bob Group [email protected] sorry]# gpasswd-a Sorry Bob       //Give Bob's permission to sorry user [[email protected] sorry]# gpasswd-a Tom BOB         //Under sorry user, Add Tom to the Bob Group adding user Tom to group BOB                       //display added [Root[email protected] sorry]# groups Tom                 //See which groups Tom users belong to C15>tom:tom Bob[[email protected] sorry]# gpasswd-d Tom Bob         //Under Sorry users, remove Tom from the BOB group removing user Tom from Group Bob[[email protected] sorry]#     

3, effective group of switching

   Newgrp

     If a user's effective group has multiple: Group 1; Group 2 ..... (The default group 1 is the main group, the other group is the sub-group);

Active Group switching: NEWGRP Group 2 user name

After switching, the user's valid group is: Group 2: Group 1 ...

   

Linux Account Management Chapter II: Management of user groups

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.