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

To Add a group: groupadd Group name

To 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  //view Likui belongs to which group  -a sorry Bob        //Add Likui to the 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------. -Sorry sorry4096June A  -: -likuidrwx------.3Tom Tom +June A  -: -Tom[[email protected] sorry]# groupadd BOB//Create a Bob group[Email protected] sorry]# gpasswd-a Sorry BOB//give Bob's permission to sorry users[Email protected] sorry]# gpasswd-a Tom BOB//under the sorry user, add Tom to the Bob GroupAdding user Tom to group BOB//the display is added in[email protected] sorry]# groups Tom//See which groups Tom users belong totom:tom bob[[email protected] sorry]# gpasswd-D Tom BOB//Delete Tom from the Bob Group under the sorry userremoving user Tom fromgroup 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);

switching of effective groups : 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.