User management tools for Linux

Source: Internet
Author: User

I. Add, toggle, delete user Group commands Groupadd/newgrp/groupdel

1. Groupadd command

Used to create a new user group. The syntax format is:

Groupadd [-g-o] GID Group

The specific meanings of each option are as follows:

-G: Specifies the GID number of the new user group, which must be unique and cannot be duplicated with the GID number of other user groups.

-O: Typically used concurrently with the-G option, which means that the GID for the new user group is the same as the GID for the system already has a user group.

For example:

Create a Linuxfans user group and a Fanslinux user group, with GID 1020 and 1030 respectively

[Root@localhost ~]# groupadd-g 1020 Linuxfans

[Root@localhost ~]# groupadd-g 1030 Fanslinux

[Root@localhost ~]# More/etc/group|grep Linuxfans

LINUXFANS:X:1020:

[Root@localhost ~]# More/etc/group|grep Fanslinux

fanslinux:x:1030:

2. NEWGRP command

If a user belongs to more than one user group, the user can switch between user groups so that they have permissions from other groups of users, and NEWGRP is primarily used to switch between multiple user groups, in the form of:

Newgrp < user group >

Example: The following is an example that describes the use of NEWGRP:

First, 3 user groups group1, group2 and Group3 were established.

[Root@localhost ~]# Groupadd group1

[Root@localhost ~]# Groupadd group2

[Root@localhost ~]# Groupadd Group3

The following creates a user User1 and specifies that the primary user group for the User1 is group1, and that the additional user group is group2 and Group3

[Root@localhost ~]# useradd-g group1-g group2,group3 user1

[Root@localhost ~]# More/etc/group|grep user1

Group2:x:501:user1

Group3:x:502:user1

The following is a password set for the user User1

[Root@localhost ~]# passwd user1

Changing password for user user1.

New UNIX Password:

Retype new UNIX Password:

Passwd:all authentication tokens updated successfully.

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.