Useradd can be used to create a user account. After the account is created, use passwd to set the password of the account, and use userdel to delete the account. The account created using the useradd command is actually saved in the/etc/passwd text file.
Syntax
Useradd [-mMnr] [-c <remarks>] [-d <logon Directory>] [-e <validity period>] [-f <buffer days>] [-g <group>]
[-G <GROUP>] [-s <shell>] [-u <uid>] [user account]
Or
Useradd-D [-B] [-e <validity period>] [-f <buffer days>] [-g <GROUP>] [-G <GROUP>] [-s <shell>]
Parameter description:
- -C <remarks> add remarks. The remarks are saved in the remarks field of passwd.
- -D <logon Directory> specifies the start directory for user login.
- -D. Change the default value.
- -E <validity period> specifies the validity period of the account.
- -F <buffer days> specifies the number of days after the password expires.
- -G <GROUP> specifies the group to which the user belongs.
- -G <GROUP> specifies the additional group to which the user belongs.
- -M automatically creates the user's logon directory.
- -M: do not automatically create a user's logon directory.
- -N cancel creating a group named by the user name.
- -R: create a system account.
- -S <shell> specifies the shell used after the user logs on.
- -U <uid> specifies the user ID.
Instance
Add normal user
# Useradd tt
Specify the corresponding user group for the added user
# Useradd-g root tt
Create a system user
# Useradd-r tt
Specify the home directory for the newly added user
# Useradd-d/home/myd tt
Create a user and specify the ID
# Useradd caow.u 544