1. Check the ID information of the user related
ID [OPTION] ... [USERNAME]
Common options:
-U: View the user's ID number
-G: View the user's base group
-G: View all groups of users
2. Switch User su
Su [OPTION] ... [-] [USER [ARG] ...]
1, SU root: Non-login switch, does not read the target user's configuration
2, Su-root: Login switch, will read the user's configuration file
3. After switching the account, execute the command and switch back: su-username-c ' command '
3. User created Useradd
useradd [Options] LOGIN
Common options:
-U UID: Specifies the user's ID number, which is used with the-o option and can use the other user's identification number
-G GID: Specifies the user's base group, which can be either a group name or a group ID, and this basic group must exist
-C COMMAND: Add a comment description
-d/home/: Add user's home directory, if directory does not exist, and M with
-S: Specifies the user's default shell,
-G: Specifies the user's additional group, the group must first exist
Note: useradd-d: is to create Default user, default user's configuration in/etc/default/useradd file
4. Modify User Attributes Usermod
usermod [Options] LOGIN
Common line selection: and Useradd is the same
-L: Modify the new user name
-G: Note that changes will overwrite the original additional group if you want to keep the-a with.
-D: Add a new home directory, the original home directory files will not be copied over. To copy, you need to use-M.
-l:lock Specifying user passwords
-U: Unlock the specified user password
5. Add password to user passwd
passwd [Options] [username] Modify the password of the specified user, the administrator uses
passwd [Username] Modify your password
Common options:-L: Lock user password
-u: Unlock user password
-N min: Minimum time for password changes
-X Max: Maximum age for password changes
-W warn: duration of warning period
-I: Stop account after expiration
--stdin: Accept user password from standard input
Eg:echo ' PASSWORD ' |passwd--stdin Tom
/dev/null: Data black hole
/dev/zero: Always output 0
6. Delete User Userdel
Userdel [Options] Username
-r: Delete User home directory
7. Group Creation Groupadd
Groupadd [-G gid [-o]] [-R] [-F] [-K key=value] Group
Common options:
-G GID: Specify Group ID
-R: Creating a System Group
8 Group Modification Groupmod
groupmod [Options] GroupName
-N: RESET Group name
-G: Re-set the group ID
9, group password add gpasswd
GPASSWD [Options] Group
-A: Adding users to Groups
-D: Delete user
-A: Specify administrator
10, group Delete Groupdel
Groupdel username
11. Temporary Switch Base Group: NEWGRP
If the user belongs to this group, does not need the password, if the account does not belong to this group, need the password.
12, modify the user password valid information chage
chage [Options] User
-D: Last Password modification time
-e: Account expiration date, the account cannot be used after this day
-I: List current settings
-M: Maximum age of password validity
-M: Minimum age at which a password can be changed
-W: How many days in advance before the user password expires.
13. PWCK: View the integrity of the current password file
CHFN: Modifying annotation information
Chsh: Modify SH;
Linux User and group-related commands