Fast browsing Basic user and user group management commands under Linux

Source: Internet
Author: User

Linux is a multi-user multitasking operating system, all users who want to use system resources must first apply to the system administrator for an account, and then enter the system as the identity of the account. The user's account can help the system administrator to track the users who use the system and control their access to the system resources, on the other hand, it can help users organize files and provide security protection for users. Each user account has a unique user name and user password. Users can enter the system and their home directory by typing the correct username and password at logon.
To achieve the user account management, the work to be done mainly has the following several aspects:
A. Add, delete, and modify user accounts.
B. Management of user passwords.
C. Management of user groups.

Management of Linux user accounts

User account management mainly involves the user account add, delete and modify.
Adding a user account is to create a new account in the system, and then assign a user number, user group, home directory, and login shell to the new account. The account you just added is locked and cannot be used.
1. Create a new Test1 user and set a password for the user

The code is as follows:

Adduser/useradd test1

passwd test1
2. New Group1 User Group
The code is as follows:

Groupadd group1

Delete a group

The code is as follows:

Groupdel group1

Modify a group

The code is as follows:

Groupmod-n group2 group1

Rename Group1 to Group2

3. Create new Test1 user and add to group1 user group

The code is as follows:

Useradd-g test1 group1

4. Increase the Working Group for existing TEST1 users group2

The code is as follows:

Usermod-g group2 Test1

Or:

The code is as follows:

Gpasswd-a test1 group2

usermod-d/home/test-g test2 Test
Note: Shel for group-D home Directory-S for-G
Change the login directory of test user to/home/test and join Test2 Group, note that this is big G.
The code is as follows:

gpasswd-d test1 group2 Removes a user test1 from a group2 group

5, temporary shutdown: In the/etc/shadow file belongs to the user's line of the second field (password) before adding * on it. To restore the user, remove the * can.

Or, use the following command to close the user account:

The code is as follows:

passwd peter–l

Re-release:

The code is as follows:
passwd Peter–u
6. Permanently delete user account
The code is as follows:

Userdel Peter

Groupdel Peter
Usermod–g Peter Peter

(forcibly deletes all files and subdirectories under this user's home directory and home directory)

7, remove users from the group
Edit/etc/group Find GROUP1 line, delete A
or by command.

The code is as follows:
gpasswd-d A GROUP
Related Article

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.