Name

useradd [options] username — shadow-utils

Synopsis

/usr/sbin stdin stdout - file -- opt --help --version

The useradd command lets the superuser create a new user account.

# useradd smith

Its defaults are not very useful (run useradd -D to see them), so be sure to supply all desired options. For example:

# useradd -d /home/smith -s /bin/bash -g users smith

Useful options

-d dir

Set the user’s home directory to be dir.

-s shell

Set the user’s login shell to be shell.

-u uid

Set the user’s ID to be uid. Unless you know what you’re doing, omit this option and accept the default.

-g group

Set the user’s initial (default) group to group, which can either be a numeric group ID or a group name, and which must already exist.

-G group1,group2,…

Make the user a member of the additional, existing groups group1, group2, and so on.

-m

Copy all files from your system skeleton directory, /etc/skel, into the newly created home directory. The skeleton directory traditionally contains minimal (skeletal) versions of initialization files, like ~/.bash_profile, to get new users started If you prefer to copy from a different directory, add the -k option (-k your_preferred_directory).

Get Linux Pocket Guide now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.