In Linux system management, we often add and delete information about users and groups, so let's learn how to create, delete, modify, and Group
Next, let's briefly describe what is a group and what is a user concept?
User:
In fact, a simple understanding is an identifier created by a file or directory.
GROUP:
A simple understanding of a group is a container that is used to give users a container for directories or files. Therefore, a group cannot log on to the system and cannot use resources.
Account and group management:
/Etc/login. defs
Shadow password suite configuration.
/Etc/passwd
User account information.
Root: x: 0: 0: root:/bin/bash
Field 1: account: Login Name
Field 2: password -->/etc/shadow
Section 3: UID:
Section 4: GID: basic group ID
Section 5: comment: account comment
Section 6: home dir: User Account HOME directory
Section 7: SHELL: the user's default shell
/Etc/shadow
Secure user account information.
Root: $1 $ AKMibarg $ G/nw/HgmH3geg66k8/keF1: 15761: 0: 99999: 7 :::
Field 1: account: Login Name
Field 2: encrypted password (if */! appears */!, The account cannot log on to the system)
Field 3: Date on which the password was recently changed
Field 4: Number of days when the password cannot be changed
Field 5: Number of days for Password Change
Field 6: warning information before the Password Change Period
Field 7: password expiration time
Field 8: Account Expiration Date
Field 9: Reserved
/Etc/group
Group account information.
Daemon: x: 2: root, bin, daemon
Field 1: account
Field 2: password
Field 3: GID-> User Group ID
Field 4: All accounts added to this group
Create a user:
Useradd [options] LOGINNAME
-U: UID (the default value is greater than or equal to 500 and cannot be repeated)
-G: GID (basic group): this group exists beforehand.
-G: GID... additional group
-C: "comment": Specifies the comment information.
-D:/path/to/directory, specifying the user's home directory
-S: Specifies shell->/etc/shells (current)
-M: When the specified home directory does not exist,-m indicates the user's home directory.
-M: do not create a home directory
Comprehensive Utilization:
Create a system user tom with the annotation information "This is a text account", and specify the ID as 111. The home directory is/home/tom3.
Change shell to/sbin/nologin and add it to mygroup.
# Adduser-r-c "This is a text account:-d/home/tom3-m-s/sbin/nologin-G mygroup
ID:
Function: view User details
Option:
-G: ID of all groups
-U: displays the user ID.
-G: Display gid
-N: Display name
For example:
View the account ID of the tom User:
# Id tom can be displayed
Userdel:
Function: delete a user.
Option:
-R: the user is deleted along with the home directory.
For example
Delete the tom user and delete the user's home directory together:
# Userdel-r tom
Usermod:
Function: Modify user account settings.
Option:
-U: UID
-G: the GID must be in the/etc/group.
-G: overwrites the existing additional group by default.
-A: append an additional group to change user groups that users can support.
-C: Specifies the comment information.
-D: Specifies the home directory.
-M: Specifies the location of the home directory. 5. Move the contents of the home directory to the current directory.
-S: Modify shell
-L: Change the username --> corresponding to the first column in the/etc/passwd file.
-E: change the password expiration time, followed by the date parameter is MM/DD/YY or YYYY-MM-DD
-L: (lock) lock the user account
-U: (unlock) unlock the user account
For example, lock the jack user account information and change the comment to "download file" # usermod-c "beause download file"-L jack