English | 简体中文 | 繁體中文 | Русский язык | Français | Español | Português | Deutsch | 日本語 | 한국어 | Italiano | بالعربية

Linux useradd command

Linux Command大全

The Linux useradd command is used to create user accounts.

The useradd command can be used to create user accounts. After the account is created, use passwd to set the account password. You can use userdel to delete the account. The accounts created using the useradd command are actually stored in /etc/It is in the passwd text file.

Syntax

useradd [-mMnr][-c <remark>][-d <login 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<remark>  Add remark text. The remark text will be saved in the remarks column of passwd.
  • -d<login directory>  Specify the starting directory for the user to log in.
  • -D  Change the default value.
  • -e<validity period>  Specify the validity period of the account.
  • -f<buffer days>  Specify the number of days after the password expires to close the account.
  • -g<group>  Specify the group the user belongs to.
  • -G<group>  Specify the additional group the user belongs to.
  • -m  Automatically create the user's login directory.
  • -M  Do not automatically create the user's login directory.
  • -n  Cancel the creation of a group named after the user name.
  • -r  Create a system account.
  • -s<shell>   Specify the shell used after the user logs in.
  • -u<uid>  Specify the user ID.

Online Examples

Add a general 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 caojh -u 544

Linux Command大全