O'Reilly logo

Linux Pocket Guide, 2nd Edition by Daniel J. Barrett

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

Name

useradd — stdin  stdout  - file  -- opt  --help  --version

Synopsis

useradd [options] username

The useradd command lets the superuser create a 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.

-c string

Set the user’s comment field (historically called the GECOS field). This is usually the user’s full name, but it can be any string. The chfn command can also set this information.

-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 dirname).

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required