CentOS 7 User Management 1

1. Create a user:
adduser phpq //Create a new phpq user
passwd phpq //Set a password for the phpq user


2. Create a workgroup
groupadd test //Create a new test workgroup


3. Create a new user and add a workgroup
useradd -g test phpq //New phpq user and add it to the test work group
Note


: -g belongs to the group -d home directory -s SHELL
used : Just add * in front of the second field (password) of the line belonging to the user in the /etc/shadow file. To restore the user, remove the *. Or use the following command to close the user account: passwd peter –l to release again: passwd peter –u 6. Permanently delete the user account userdel peter groupdel peter usermod –G peter peter (force delete the user’s home directory and all files in the home directory and subdirectories)



















7. Delete a user from the group
Edit /etc/group to find the GROUP1 line, delete A or use the command gpasswd -d A GROUP


8. Display user information
id user

cat /etc/passwd

9
Supplement: How to view users and user groups
User List file: /etc/passwd
User group list file: /etc/group

Check which users are in the system:
cut -d : -f 1 /etc/passwd
Check the users who can log in to the system: cat /etc/passwd | grep -v /sbin/nologin | cut -d : -f 1
View user operations: w command (requires root privileges)
View a user: w username
View logged in users: who
View user login history: last

Guess you like

Origin http://43.154.161.224:23101/article/api/json?id=326402926&siteId=291194637
Recommended