linux user
Related configuration files
- Linux mainly uses the user configuration file to view and modify user information
etc/passwd
The first field: user name
The second field: password flag (indicating that the user has a password, and the password is placed in the etc/shadow file)
The third field: UID user id number (id is 0, it means it is root user, ordinary user Starting from 500)
Fourth field: initial user group id
Fifth field: user description
Sixth field: home directory (ordinary user in /home/username, root user in /root/)
Seventh field: shell- etc/shadow shadow file
- etc/group group information file
- etc/gshadow group password file
home/username user's home directory
User management commands
- useradd username to add a user
- passwd username to add the password of the corresponding user
- passwd can only be operated by the root user in many cases
- passwd -l username locks the user (equivalent to adding shadow before the corresponding user password!)
- passwd -u username to unlock the user (equivalent to remove the shadow before the corresponding user password!)
- usermod username to modify user information
- chage username to change the password status (can be used to prompt the user to change the password immediately after logging in)
- userdel -r Username deletes the user and deletes the corresponding home directory
- whoami View the username of the currently logged in user
- su - root switch user (the minus sign in the middle means switch user environment variables at the same time, so be sure to bring it)
- su - root -c "corresponding command" Execute the corresponding command as root without switching users