Nameuseradd [man page] - create a new user or update default new user information
useradd [options] LOGIN
useradd -D [options]
Frequently used options
-c, --comment COMMENT
Any text string. It is generally a short description of the login,and is currently used as the
field for the user’s full name.
-d, --home HOME_DIR
The new user will be created using HOME_DIR as the value for the user’s login directory. The
default is to append the LOGIN name to BASE_DIR and use that as the login directory name.
The directory HOME_DIR does not have to exist but will not be created if it is missing.
The user’s home directory will be created if it does not exist. The files contained in
SKEL_DIR will be copied to the home directory if the -k option is used, otherwise the files
contained in /etc/skel will be used instead. Any directories contained in SKEL_DIR or
/etc/skel will be created in the user’s home directory as well. The -k option is only valid
in conjunction with the -m option. The default is to not create the directory and to not copy
any files. This option may not function correctly if the username has a / in it.
-s, --shell SHELL
The name of the user’s login shell. The default is to leave this field blank, which causes
the system to select the default login shell.
ExamplesLinux command useradd is used to create user account on linux ( unix ) systems. Using command useradd command without any options will only create user account in /etc/passwd file. Let's create user account for user "debian".
To force useradd command to create home directory for a new user as well as create command, copy template files from /etc/skel directory and change default shell, we need to use the following options:
useradd -m -c "Test User" -s /bin/false debian
Another helpful option for linux useradd command is -D which list system default values: