Manage user groups in Linux

Source: Internet
Author: User
Article Title: Manages user groups in Linux. Linux is a technology channel of the IT lab in China. Includes basic categories such as desktop applications, Linux system management, kernel research, embedded systems, and open source.

Each user has a user group. The system can centrally manage all users in a user group. Different Linux systems have different user groups. For example, a user in Linux belongs to a user group with the same name as a user group, which is created at the same time.

User Group management involves adding, deleting, and modifying user groups. The addition, deletion, and modification of a group are actually updates to the/etc/group file.

Add a new user group to use the groupadd command. The format is as follows:

Groupadd option User Group

You can use the following options:

-G GID specifies the group ID (GID) of the new user group ).

-O is generally used together with the-g option, indicating that the GID of the new user group can be the same as the GID of the existing user group in the system.

For example:

# Groupadd group1

This command adds a new group group1 to the system. The Group ID number of the new group is added with 1 on the basis of the current largest group ID number.

# Groupadd-g 101 group2

This command adds a new group group2 to the system and specifies that the Group ID of the new group is 101.

To delete an existing user group, run the groupdel command in the following format:

Groupdel User Group

For example:

# Groupdel group1

This command deletes group group1.

Use the groupmod command to modify the attributes of a user group. The syntax is as follows:

Groupmod option User Group

Common options include:

-G GID: specify a new group ID for the user group.

-O and-g options are used at the same time. The new GID of a user group can be the same as the GID of an existing user group in the system.

-N new user group: Change the user group name to a new name.

For example:

# Groupmod-g 102 group2

This command changes the group ID of group group2 to 102.

# Groupmod? G 10000-n group3 group2

This command changes the ID of group group2 to 10000 and the group name to group3.

If a user belongs to multiple user groups at the same time, you can switch between user groups to have permissions for other user groups. After logging on, you can use the newgrp command to switch to another user group. The parameter of this command is the target user group. For example:

$ Newgrp root

This command switches the current user to the root user group, provided that the root user group is indeed the user's main group or additional group. Similar to user account management, user group management can also be completed through integrated system management tools.

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.