Search notes:

Shell command useradd: create new user or update default new user information

useradd creates a new user or updates default new user information.
It is a low level utility. Therefore, you might want to use adduser.
$ useradd -s /bin/bash -m  rene
-s specifies the default shell for the new user. If not specified, it takes the value of SHELL variable in /etc/default/useradd.
-m creates the new user's home directory if it does not exist.

Adding a user to a group (for example sudo)

usermod can be used to add an already created user to an already created group:
$ usermod -a -G sudo rene
Make sure that /etc/sudoers is configured to allow users in the sudo group to execute sudo commands.

Populating the users home directory (-k)

By default, the home directory of a new user is populated with the files from the SKEL variable in /etc/default/useradd (default: /etc/skel/*).
This directory can be overwritten with -k /path/to/directory.
In order to not create any files in the home directory, use -k /dev/null.

Not adding the user to the faillog and lastlog databases (-l)

When -l is specified, the user is not added to the faillog and lastlog databases.

Changing the users password

After creating a user, the password for the user might be set with passwd
useradd -m rene
passwd rene

Defaults

Some defaults (such as if a Home directory should be created) are configured in /etc/login.defs

See also

A user is removed/deleted with userdel and modified with usermod.
Shell commands such as groupadd and passwd.

Index