useradd new username //add new user without any parameters
userdel username //delete user
passwd username //Change the password for an existing user
groups //View the groups the current user belongs to
groups username //View the groups to which a specific user belongs
groupadd group name //add group
groupdel group name //delete group
chmod 775 folder name //Modify the permissions of the folder
chmod -R 775 folder name //Recursively modify the permissions of folders and subordinate files
usermod -g groupname userName // Modify the group groupname to which the user belongs to the new group name, and userName is the user name to be modified
usermod -d homepath username //Modify the user's home directory homepath is the new home directory, username is the username to be modified
Files related to users and groups
/etc/passwd: user configuration file, storing user information; from left to right: user name, password (without displaying plain text), user id, group id, home directory, login shell.
/etc/shadow: password configuration file, used to store information such as encrypted passwords, modification events, and expiration times.
/etc/group: group configuration file, used to store group name and group id.
Relationship between files and users and groups
When a user creates a file, the user automatically becomes the "owner" of the file, and the group the user belongs to becomes the "group" of the file. Except for the owner and the users in the group, other users in the system have no control over the file. The files are all for "other group" users. You can use the ls -l command to view the owner and group of the file. However, the owner and group of the file are not fixed and can be modified.
13. Modify the owner of a file or directory
chown [-R] username source
Among them, username is the modified user name, source is the path name of the file or directory, and -R indicates the owner of the subdirectories and files under the cascade modification directory.
14. Modify the group of the file or directory
chgrp [-R] groupname source
Among them, groupname is the modified group name, source is the path name of the file or directory, and -R indicates the group where the subdirectories and files under the directory are cascaded to be modified. Note that modifying the owner and group of a file is an independent event and does not affect each other.
15. Modify the owner and group of the file or directory at the same time
chown [-R] username:groupname source
linux centos add user
Guess you like
Origin blog.csdn.net/u014285237/article/details/128830760
Recommended
Ranking