32.2.2. Adding a User
To add a user to the system:
Command line options for useradd are detailed in Table 32.1, “useradd Command Line Options”.
| Option | Description |
|---|---|
-c '<comment>'
|
<comment> can be replaced with any string. This option is generally used to specify the full name of a user.
|
-d<home-dir>
|
Home directory to be used instead of default /home/
|
-e<date>
|
Date for the account to be disabled in the format YYYY-MM-DD |
-f<days>
|
Number of days after the password expires until the account is disabled. If 0 is specified, the account is disabled immediately after the password expires. If -1 is specified, the account is not be disabled after the password expires.
|
-g<group-name>
|
Group name or group number for the user's default group. The group must exist prior to being specified here. |
-G<group-list>
|
List of additional (other than default) group names or group numbers, separated by commas, of which the user is a member. The groups must exist prior to being specified here. |
-m
|
Create the home directory if it does not exist. |
-M
|
Do not create the home directory. |
-n
|
Do not create a user private group for the user. |
-r
|
Create a system account with a UID less than 500 and without a home directory |
-p<password>
|
The password encrypted with crypt
|
-s
|
User's login shell, which defaults to /bin/bash
|
-u<uid>
|
User ID for the user, which must be unique and greater than 499 |
Table 32.1. useradd Command Line Options