This article summarizes some of the commands and parameters that are commonly used when adding or removing users and user groups from Linux. 1, build users: AddUser phpq passwd PHPQ 2, build Working Group Groupadd Test 3, Create new user at the same time add Workgroup useradd-g Test PHPQ Note::-G belongs to the group-D home Directory-S used by Shell 4, to existing users add Workgroup usermod-g groupname username or: GPASSW D-a User Group 5, temporary shutdown: The second field (password) in the/etc/shadow file that belongs to the user is preceded by a *. To restore the user, remove the *. 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 (Force delete all files and subdirectories in the user's home directory and home directory) 7, remove user edit from group/etc/group find GROUP1 Line, delete A or use command gpasswd-d a group 8, display user information ID users cat/etc/passwd
Common Chitian Detailed:
To view the user group commands for the current user:
[[email protected] opt] #groups
Root bin daemon Sys adm disk wheel
Output information, the first user group is a valid user group for the current user (current user group)
To toggle a valid user group command:
[[email protected] opt] #newgrp user group name
To leave the new active user group, enter exit carriage return.
New User command:
[[email protected] opt] #useradd username
-G Initial user group-G Other user groups (modify/etc/group)-C User Instructions-u specify UID
Users need to set a password for the user:
[[email protected] opt] #passwd username
The user wants to modify their password command:
[[email protected] opt] #passwd
To modify the user Information command:
[[email protected] opt] #usermod parameter user name
Parameters:-C Description-G Group name Initial user group-e Expiration date format: YYYY-MM-DD-G group name Other user group-l modify user name-L lock account (in the/etc/shadow file, the user corresponding password password string in front of the two exclamation mark (!!) )-U unlock
To delete a user command:
[[email protected] opt] #userdel [-r] User name
where the parameter-R is the home directory for the user to delete. In fact, there may be other places in the system also has the user file, to complete delete a user and its files to find the file belongs to him first: [[email protected] opt] #find/-user user name then delete, then run Userdel delete the user.
To view the available shell commands:
[[email protected] opt] #chsh-l
To modify your own shell command:
[[email protected] opt] #chsh-s
View yourself or someone uid/gid information:
[[email protected] opt] #id [user name]
Return information in groups as a valid user group
New User Group command:
[[email protected] opt] #groupadd user group name
To modify a user group name command:
[[email protected] opt] #groupmod-n Name
To delete a user group command:
[[email protected] opt] #groupdel user group name
Set User Group Password command:
[[email protected] opt] #gpasswd user group name
If the GPASSWD plus parameter has other functions
Set User Group Administrator command:
[[email protected] opt] #gpasswd-a user name user group name
Add an account to group command:
[[email protected] opt] #gpasswd-m user name user group name
To remove an account command from a group:
[[email protected] opt] #gpasswd-d user name user group name
passwd related parameters Operation:-L lock User-u unlock user-n days password No day number-X days password expires days-W days warning days
Knowledge of file permissions:
Modify a file to belong to the Group command:
[[email protected] opt] #chgrp [-r] Group name file name
Where-R is the recursive setting
To modify the owner and group commands for a file:
[[email protected] opt] #chown [-r] User [: User Group] File name
To modify File access Permissions command:
[[email protected] opt] #chmod [-RV] 0777 file name
-V: Show details of permission changes
-r: The same permissions change for all files in the current directory and subdirectories (i.e., recursively changing one by one)
[[email protected] opt] #chmod ABC file name
Each of the a,b,c is a number that represents the permissions of the user, Group, and other respectively. R=4,w=2,x=1 to rwx the property is 4+2+1=7, 4+2=6 to rw-property, or R-x to 4+1=5 property.
Linux users and Groups Chitian Daquan