linux-user management commands

1: User add command useradd [option] User name, when adding a new user (use useradd user name directly), generally in / etc / passwd, / etc / shadow, / etc / group / etc / gshadow, / home / yo /, / var / spool / mail /, explained the above directory in the previous articles

Options: -u UID: manually specify the user's UID number

           -d home directory: manually specify the user's home directory

           -c user description: manually specify the user's description

           -g group name: manually specify the user's initial group

           -G group name: manually specify additional groups of users

           -s shell: Manually specify the user's login shell. The default is / bin / bash

Direct use of useradd username will also generate users. These default configuration files are in / etc / default / uesradd and /etc/login.defs

  /etc/default/uesradd

/etc/login.defs represents the encryption algorithm

/etc/login.defs

2: Modify the user password passwd [option] username (you can set the password for the user directly by using the passwd username). If you want to change the password, you can also use [passwd username] directly, but the prerequisite is the root user. Ordinary users can only modify their own passwords, and use passwd directly without adding a user name, otherwise an error will be reported. Not adding also means to modify the current user's password.

Options: -S Query the password status of the user's password. Only root user is available

           -l temporarily lock the user, only the root user is available

          -u Unlock the user. Only root users can use

          --stdin can use the pipe output data as the user's password

This can be used to add passwords in batches--stdin means accept strings as passwords

3: Modify user information usermod, the difference with useradd is that usermod is used to modify existing users, and useradd is used to add new users.

usermod [options] username

Options: The options usermod can be used by general useradd

-L: temporarily lock the user

one more! Indicates that the user cannot be used

-U: unlock user lock

4: Change user password status chage

charge [options] username

Options: -l (L lower case): List the detailed password status of the user

           -d date: the last time the password was changed (shadow3 field)

           -m days: two password change intervals (4 fields)

          -M days: password validity period (5 fields)

          -W days: warning days before password expiration (6 fields)

          -I (i uppercase) days: grace days after password (7 fields)

         -E date: account expiry time (8 fields) 

charge -d 0 username: it can force the user to change the password;

5: Delete user userdel

userdel [-r] User name -r means delete the user's home directory at the same time as deleting the user

6: View user ID 

id username

7: user switching command su

su [options] username

-: The option only uses "-" to switch together with the user's environment variables

-c command: execute the command only once without switching the user's identity

The env command can be used to view user environment variables

The reason for the error is that there is no "-" after su

Super users do not need to enter a password when switching users, but ordinary users need to enter a password when switching users.

Indicates not to switch to root, but execute the useradd command to add user2

Published 148 original articles · Like 10 · Visitors 20,000+

Guess you like

Origin blog.csdn.net/ab1605014317/article/details/105058615