System Management Commands USERADD(8) linux
useradd - create a new user or update default new user information
useradd [options] loginName
Creates a new user account using the values specified on the command line and the default values from the system. May create the
new user's home directory and copy initial files there.
Some versions will create a group for each user added to the system by default.
sudo adduser --comment "firstname lastname" --create-home flastname
sudo passwd flastname
| Numerical |
uid, unsigned, and unique, (unless the
-o is used).
Default uses the next higher number than currently exists.
0 - 999 are typically reserved for system accounts.
| Allow the creation of a user with a non-unique |
uid, a synonum.
| group name or number for the user's initial group, refering to an existing group.
| list of supplementary groups of which the user is also a member, separated by commas, with no intervening whitespace. The groups are subject to the same restrictions as the group given with the |
This option turns off the Red Hat Linux specific behavior to create group having the same name as the user being added .
When this option is used, users by default will be placed in whatever group is specified in
If no default group is defined, group 1 will be used.
| generally a short description of the login, and is used
as the field for the user's full name.
| Create home directory. |
Files contained in
/etc/skel will be copied there.
skel_dir will be created in the user's home directory .
-k is only valid in conjunction with
-m . )
Default does not create the directory and does not copy files.
| default base directory for the system if |
-d dir is not specified.
base_dir is concatenated with the account name to define the home directory.
-m is not used,
base_dir must exist.
| New user's login directory, will not be created.|
|The user's home directory will not be created.
| The encrypted password, as returned by |
The default is to have the account disabled.
Since it is nearly impossible to correctly enter the crypted password, my advise is to leave the account disabled, then enter the password using
sudo passwd loginName
| date the account will be disabled,
| grace period, in days, after a password expires, after which the account is disabled. |
0 disables the account as soon as the password has expired, and
-1 disables password ageing.
The default value is -1.
| Overrides |
/etc/login.defs defaults (
UID_MIN, UID_MAX, UMASK,
PASS_MAX_DAYS and others).
-K PASS_MAX_DAYS=-1 can be used when creating system account to turn off password ageing, even though system account has no password at all.
-K entries can be specified, e.g.:
| This flag is used to create a system account. That is, a user with a |
UID lower than the value of UID_MIN defined in
/etc/login.defs and whose password does not expire no a home directory is created unless
-m is present. This is an option added by Red Hat
| login shell. The default leaves this field blank, which causes the system to select the default login shell.
-l lower case L
| Do not add the user to the last login log file.
| The SELinux user for the user's login. The default is to leave this field blank, which causes the system to select the default SELinux user.
| Display help message and exit.
When invoked with
-D either display the current default values, or
update the default values from the command line.
| initial path prefix for a new user's home directory. The user's name will be affixed
to the end of |
home_dir to create the new directory name if the
-d is not used when creating a new account.
| date on which the user account is disabled.
| number of days after a password has expired before the account will be disabled.
| group name or ID for a new user's initial group, must exist, and a
numerical group ID must have an existing entry.
| name of the new user's login shell to be used for all future new user accounts.
If no options are specified, useradd displays the current default values.
The system administrator is responsible for placing the default user files in
Adding a user to a NIS group must be performed on the NIS server.
if the username already exists in an external user database such as NIS, useradd
will deny the user account creation request.
| User account information.
| Secure user account information.
| Group account information.
| Secure group account information.
| Default values for account creation.
| Directory containing default files.
| Shadow password suite configuration.
1 can't update password file
2 invalid command syntax
3 invalid argument to option
4 UID already in use (and no -o)
6 specified group doesn't exist
9 username already in use
10 can't update group file
12 can't create home directory
13 can't create mail spool
userdel, usermod, chfn, chsh, passwd, crypt, groupadd, groupdel, groupmod, login.defs,
System Management Commands 06/24/2006 USERADD(8)