1. Add user 1. useradd-set option User name [-D view default parameters] option: u: UID [must not be in the system] g: default user group GIDG: specify multiple groups to which the user belongs. you can specify the Department of the user. d: Host
I,
Add user
1. useradd-set option username [-D view default parameters]
Option:
U: UID (which must not be in the system]
G: default user group GID
G: Specify multiple groups to which the user belongs. you can specify the department to which the user belongs]
D: home directory (which can be specified at will theoretically]
S: command interpreter Shell [must be included in the/etc/shells file]
C: description [used to describe who the user is and what permissions does the user have]
E: specifies the User Expiration Time.
E. g. sudo useradd-u 6666-g root-G sys, apache-d/home/jack-s/bin/bash-c "Project manege"-e 2014-2-23 jack
[View useradd help, man useradd]
2. set password: passwd test
Command to delete a user:
1. userdel username // delete the user, but the user's home directory is retained
2. userdel-r user name //-r deletes the user's home directory
2. add a group
Groupadd webadmin
Or: groupadd-g 8888 webadmin //-g to specify GID = 8888
Save group information in the/etc/group file]
3. add a user to a group
[Practical significance of adding users to a group: if a file needs to grant special permissions to several users, add these users to the group]
Method 1,
Usermod-G group name username
Method 2: [simple commands for user group management]
Gpasswd-a username group name [this command is not generally used in UNIX systems]
-D. delete a user from the user group.
-A: set the user group administrator.
-R: delete user group password
-R: prohibit users from switching to this group, for example, gpasswd-R webadmin.
Set a password for the group: gpasswd webadmin
Save the group password in the/etc/gshadow file]
[Instance expansion]
Switch the current user to a new group: newgrp
Enter the password :*****
View current account information: id
View the group to which the current user belongs: groups
IV. integration:
[User authorization case]
Grant the directory/software write permission to jack and mary.
1. create a directory: mkdir/software
2. add Group: groupadd softadm
3. add a user to the group: usermod-G softadm jack
Gpasswd-a mary softadm
4. change the directory group: chgrp softadm/software
5. change the directory Group permission: chmod g + w/software
6. view the directory information: ls-ld/software
[Drwxrwxr-x 2 root softadm]
5. user management commands
Pwck detection/etc/passwd file
If an incorrect operation is performed on/etc/passwd, the system will prompt
Vipw edits the/etc/passwd file. The only difference between vipw and VI will lock the/etc/passwd file.
Id to view user id and group information
Finger view user details
Su switching user
[Su-there will be an environment variable to switch to the home directory at the same time [added-,-left and right use space], and su will not]
Note: You do not need to enter a password to switch from the root user.
Passwd-S to view the user password status
Passwd-d delete user password
Passwd-l the user or usermod-L xiaofang can also be locked.
[Usage: for example, this user has violated the rules and is not required for a long time]
Principle analysis: add one or two more passwords to the/etc/shadow file! Because the length of the md5 encryption password is fixed, in this case, the password cannot match! Therefore, the system administrator can manually lock an account.
Passwd-u unlock user or usermod-U
Who and w view current login user information
Users logging on locally: ppy1, ppy2...
Remote login users: pts/1, pts/2...
W is displayed in more detail:
Format Time: up logon Time: several users: system load at several time points...
Set the chage password [not in UNIX]
-L view user password settings
-M: minimum number of days for password modification
-Maximum number of days for M password modification
-D Date of last password modification
-I. The number of days the account is locked after the password expires
-E: Set the password expiration date. if it is 0, the password will expire immediately. if it is-1, the password will never expire.
-W: set the number of days before the password expires.
IV. User Group management commands
1. add a user group:
Groupadd name
Groupadd-g 888 webadmin creates a user group webadmin with a GID of 888
2. delete a user group:
Groupdel group name
3. modify User Group Information:
Groupmod-n
Groupmod-n apache webadmin // modify the name of the webadmin group to apache.
4. expansion command:
Group
Newgrp switching user group
Grpck user group configuration file detection [similar to pwck usage and significance, see the above]
Chgrp modify the group to which the file belongs
Vigr: when editing the/etc/group file and editing it, the file is locked
5. Integrated instances
[Manually delete a user]
Use the find command to find files belonging to a user or user group:-user,-uid,-group,-gid
For example, find/home-user test
1. move and back up files to be retained
2. delete unnecessary files
3. clear related table items in the user file
4. clear the user's home directory
6. expansion:
[Start or disable the shadow function]
1. pwconv/pwunconv
Kgconv/grpunconv
2. more powerful tool provided by Linux: authconfig can change many settings
Permanently Valid: edit/etc/sysconfig/authconfig
[Use graphical tools to manage users]
System-config-users [not recommended]