Click the blue text above to follow us




-
UID: User Identifier -
GID: Group Identifier
-
Saves basic information such as user names, home directories, and login shells. -
File location: /etc/passwd. -
Each line corresponds to a user’s account record.

root:x:0:0:root:/root:/bin/bashField 1: User account name (root)Field 2: Password placeholder "x" (x)Field 3: User account UID number (0)Field 4: GID number of the associated primary group account (0)Field 5: Full name of the user (root)Field 6: Home directory (/root)Field 7: Login shell information (/bin/bash allows login; /sbin/nologin and /bin/false prohibit user login.)Note: In Field 7, /bin/nologin is denied login with a refusal message; /bin/false has no message

root:$6$VyOUGqOC$v5HlLM1wagZC/FwGfnrtJFnlT:18445:0:99999:7:::Field 1: User account name (root)Field 2: MD5 encrypted password string. When it is "*" or "!!", it indicates that this user cannot log into the system. If this field is empty, the user can log in without a password ( $6$VyOUGqOC$v5HlLM1wagZC/FwGfnrtJFnlT)Field 3: The last time the password was changed, expressed as the number of days since January 1, 1970 (18445)Field 4: Minimum password age, the user must wait this number of days after changing the password before changing it again. Default is 0, meaning no restriction (0)Field 5: Maximum password age, after this number of days, the user must change the password again. Default is 99999, meaning no restriction (99999)Field 6: Number of days before expiration to warn the user (default is 7) (7)Field 7: Number of days after password expiration to disable this user (empty)Field 8: Account expiration date, specified in days since January 1, 1970, default is empty, meaning the account is permanently available (empty)Field 9: Reserved field (not used) (empty)Note: Fields 7, 8, and 9 are rarely used, generally default to understand
Format: useradd [options] username
Common options: -u: Specify the user's UID number, which must not be in use by another user.-d: Specify the user's home directory location (does not take effect when used with -M).-e: Specify the user's account expiration date, can use YYYY-MM-DD date format.-g: Specify the user's primary group name (or use GID number), the corresponding group name must already exist.-G: Specify the user's additional group name (or use GID number), the corresponding group name must already exist.-M: Do not create a home directory.-s: Specify the user's login shell (e.g., /bin/bash allows login; /sbin/nologin and /bin/false prohibit user login).For example: useradd -d /admin -g wheel -G root admin1 useradd -e 2020-12-31 -s /sbin/nologin admin2



Command format: passwd [options] usernameCommon options: -d: Clear the specified user's password, allowing login using only the username.-l: Lock the user account, locked accounts will no longer be able to log into the system.-S: Check the status of the user account (whether it is locked).-u: Unlock the user account. (-u unlocks, if there is no password, it will prompt, use -f to force unlock)



Command format: usermod [options] usernameCommon options: -u: Modify the user's UID number.-d: Modify the user's home directory location.-e: Modify the user's account expiration date, can use YYYY-MM-DD date format.-g: Modify the user's primary group name (or use GID number).-G: Modify the user's additional group name (or use GID number).-s: Specify the user's login shell.-l: Change the user's login name.-L: Lock the user account.-U: Unlock the user account.

Command format: userdel [-r] usernameAdding the "-r" option will delete the user's home directory as well

