create a new user or update default new user information

adduser [--home dir]|[--no-create-home]
         [--uid id] [--firstuid id] [--lastuid ID] | --gid ID][--ingroup group ] [--add_extra_groups]
        [--shell shell] [--disabled-password] [--disabled-login]
         [--conf file]         [--system]
        [--quiet] [--debug] [--force-badname] [--help|-h] [--version] [--conf file]

addgroup [--system] [options] [--gid ID] group
adduser [options] user group

# use same UID on all systems.

sudo adduser -c "Dennis German" --home  /home/dgerman dgerman --uid 501 --gid 50  --groups staff,sudo
adduser: `Dennis German' does not exist. Using defaults.
Adding user `dgerman' ...
Creating home directory `/home/dgerman' ...
Copying files from `/etc/skel' ...none
Enter new UNIX password: 
Retype new UNIX password: 
passwd: password updated successfully
Changing the user information for dgerman
Enter the new value, or press ENTER for the default
    Full Name []: Dennis German
    Room Number []: 
    Work Phone []: 
    Home Phone []: 862-210-9339
    Other []: 
Is the information correct? [Y/n] y
sudo passwd user


create a new user or update default new user information

useradd [options] loginName

Adds a new user account. 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.


useradd -D # update Defaults

--uid uid
Numerical uid, unsigned, and unique, (unless the -o is used).
Useful for having the same UID for the same user across multiple systems.
Default uses the next higher number than currently exists.
0-999 are typically reserved for system accounts.
# show the last 8 (non system ) UIDs used
sort -t ':' -n -k 3 /etc/passwd |cut -d : -f1,3|grep -v ':[[:digit:]]\{1,3\}$' |tail -n8 |head -n -1 
Allow the creation of a user with a non-unique uid which is a synonm for other users with the same UID.
--gid group
existing group name or number for initial group. Some systems require GID
# show groups in use
grep -v ':$' /etc/group |sort|sed "s/:x//"|column
-groups g1[,g2,…[,gn]]]
Existing Groups of which user is a member.
No default.
-n no group having the same name as the user will be created.
User will be in group specified in /etc/default/useradd. If no default group 1 will be used.
--comment comment
full name.

--skel skel_dir

Create home directory with files contained in /etc/skel.
Directories in /etc/skel or skel_dir will be created in the user's home directory .
-k overrides /etc/skel, only valid with -m . )
Default: Do not create the directory.
-M home directory will not be created.
--home home_dir
don't create login directory.
Default: concatonate base_dir and login
--base-dir base_dir
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.
If -m is not used, base_dir must exist.
--shell shell
login shell. The default leaves this field blank, which causes the system to select the default login shell.
--password password
encrypted password, as returned by crypt.
The default is to have the account disabled.
Suggestion: leave the account disabled, then enter the password using sudo passwd loginName
--expiredate yyyy-mm-dd
date the account will be disabled,
--inactive days
grace period, 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.
--key KEY=value
Overrides /etc/login.defs defaults (UID_MIN, UID_MAX, UMASK, PASS_MAX_DAYS and others).
Example: -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.
Multiple -K entries can be specified, e.g.: -K UID_MIN=100 -K UID_MAX=499
-r 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.
-l (lower case L) /var/log/lastlog is not updated for this user.
--selinux-user seuser
For Security-Enhanced Linux. Default blank,

with -D displays defaults or updates defaults.

-b home_dir initial path prefix for 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.
-e expire_date date account is disabled.
-f days days after a password has expired before the account will be disabled.
--gid group
group name or ID for initial group, must exist, and a numerical group ID must have an existing entry.
--shell shell

If no options are specified, useradd displays the current default values.

The system administrator is responsible for placing the default user files in /etc/skel .

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.


/etc/passwd User account information.
/etc/shadow Secure user account information.
/etc/group Group account information.
/etc/gshadow Secure group account information.
/etc/default/useradd Default values for account creation.
/etc/skel/ Directory containing default files.
/etc/login.defs Shadow password suite configuration.


0 success
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

See userdel, usermod, chfn, chsh, passwd, crypt, groupadd, groupdel, groupmod, login.defs,

sample group file

From Raspberry pi 2/20/18
Many have no members
cat group nogroup:x:65534: root:x:0: daemon:x:1: bin:x:2: sys:x:3: adm:x:4:pi tty:x:5: disk:x:6: lp:x:7: mail:x:8: news:x:9: uucp:x:10: man:x:12: proxy:x:13: kmem:x:15: dialout:x:20:pi fax:x:21: voice:x:22: cdrom:x:24:pi floppy:x:25: tape:x:26: sudo:x:27:pi audio:x:29:pi dip:x:30: www-data:x:33: backup:x:34: operator:x:37: list:x:38: irc:x:39: src:x:40: gnats:x:41: shadow:x:42: utmp:x:43: video:x:44:pi sasl:x:45: plugdev:x:46:pi staff:x:50:dgerman games:x:60:pi users:x:100:pi,dgerman input:x:101:pi systemd-journal:x:102: systemd-timesync:x:103: systemd-network:x:104: systemd-resolve:x:105: systemd-bus-proxy:x:106: crontab:x:107: netdev:x:108:pi pi:x:1000: messagebus:x:109: ssh:x:110: bluetooth:x:111: avahi:x:112: spi:x:999:pi i2c:x:998:pi gpio:x:997:pi


useradd, groupadd and usermod