Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

Teach you to play Linux- user group management.

2025-01-27 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Servers >

Share

Shulou(Shulou.com)06/02 Report--

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

The management of user groups involves the addition, deletion and modification of user groups. Group additions, deletions, and modifications are actually updates to the / etc/group file.

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

The options you can use are:

-g GID specifies the group identification number (GID) of the new user group.

-o is generally used in conjunction with the-g option to indicate that the GID of a new user group can be the same as the GID of an existing user group on the system.

Example 1:

# groupadd group1

This command adds a new group group1 to the system, and the group identification number of the new group is added 1 to the current largest group identification number.

Example 2:

# groupadd-g 101 group2

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

2. If you want to delete an existing user group, use the groupdel command in the following format: groupdel user group

For example:

# groupdel group1

This command removes the group group1 from the system.

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

Common options are:

-g GID specifies a new group identification number for the user group.

Using the-o option with the-g option, the new GID of the user group can be the same as the GID of the existing user group of the system.

-n New user group changes the name of the user group to a new name

Example 1:

# groupmod-g 102 group2

This command changes the group identification number of the group group2 to 102.

Example 2:

# groupmod-g 10000-n group3 group2

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

4. If a user belongs to multiple user groups at the same time, the user can switch between user groups in order to have the permissions of other user groups.

After logging in, the user can switch to another user group using the command newgrp, whose parameter is the destination 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 primary or additional group of the user. Similar to the management of user accounts, the management of user groups can also be accomplished through integrated system management tools.

Original address: https://www.linuxprobe.com/user-group-management.html

Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.

Views: 0

*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

Share To

Servers

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report