CentOS system Add/Remove user and user group examples

Source: Internet
Author: User

1, Build Users:

AddUser PHPQ//New PHPQ User
passwd PHPQ//Set Password to PHPQ user

2, the establishment of the Working Group
Groupadd test//New test Workgroup

3, new users to increase the team at the same time
USERADD-G test PHPQ//new PHPQ user and add to test workgroup

Note:: The shell used by the group-D home Directory-S for-G

4, to the existing user to increase the Working group

USERMOD-G groupname username

Or: Gpasswd-a user 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:

passwd peter–l

Re-release:

passwd Peter–u

6. Permanently delete user account

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 use command gpasswd-d a group

8. Display user Information

ID User
cat/etc/passwd

Add: Ways to view users and user groups

User list file:/etc/passwd
User group list file:/etc/group

See which users are in the system: cut-d:-F 1/ETC/PASSWD
View users who can log on to the system: CAT/ETC/PASSWD | Grep-v/sbin/nologin | Cut-d:-F 1
View user actions: W command (requires root permission)
View a User: W user name
View Logged-in users: Who
View user logon history: Last

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.