1USERADD(8) System Management Commands USERADD(8)
2
3
4
6 useradd - create a new user or update default new user information
7
9 useradd [options] LOGIN
10
11 useradd -D
12
13 useradd -D [options]
14
16 When invoked without the -D option, the useradd command creates a new
17 user account using the values specified on the command line and the
18 default values from the system. Depending on command line options, the
19 useradd command will update system files and may also create the new
20 user's home directory and copy initial files. The version provided with
21 Red Hat Linux will create a group for each user added to the system by
22 default.
23
25 The options which apply to the useradd command are:
26
27 -c, --comment COMMENT
28 Any text string. It is generally a short description of the login,
29 and is currently used as the field for the user's full name.
30
31 -b, --base-dir BASE_DIR
32 The default base directory for the system if -d dir is not
33 specified. BASE_DIR is concatenated with the account name to define
34 the home directory. If the -m option is not used, BASE_DIR must
35 exist.
36
37 -d, --home HOME_DIR
38 The new user will be created using HOME_DIR as the value for the
39 user's login directory. The default is to append the LOGIN name to
40 BASE_DIR and use that as the login directory name. The directory
41 HOME_DIR does not have to exist but will not be created if it is
42 missing.
43
44 -e, --expiredate EXPIRE_DATE
45 The date on which the user account will be disabled. The date is
46 specified in the format YYYY-MM-DD.
47
48 -f, --inactive INACTIVE
49 The number of days after a password expires until the account is
50 permanently disabled. A value of 0 disables the account as soon as
51 the password has expired, and a value of -1 disables the feature.
52 The default value is -1.
53
54 -g, --gid GROUP
55 The group name or number of the user's initial login group. The
56 group name must exist. A group number must refer to an already
57 existing group. /etc/default/useradd.
58
59 -G, --groups GROUP1[,GROUP2,...[,GROUPN]]]
60 A list of supplementary groups which the user is also a member of.
61 Each group is separated from the next by a comma, with no
62 intervening whitespace. The groups are subject to the same
63 restrictions as the group given with the -g option. The default is
64 for the user to belong only to the initial group.
65
66 -h, --help
67 Display help message and exit.
68
69 -M The user's home directory will not be created, even if the system
70 wide settings from /etc/login.defs is to create home dirs.
71
72 -m, --create-home
73 The user's home directory will be created if it does not exist. The
74 files contained in SKEL_DIR will be copied to the home directory if
75 the -k option is used, otherwise the files contained in /etc/skel
76 will be used instead. Any directories contained in SKEL_DIR or
77 /etc/skel will be created in the user's home directory as well. The
78 -k option is only valid in conjunction with the -m option. The
79 default is to not create the directory and to not copy any files.
80
81 -l Do not add the user to the last login log file. This is an option
82 added by Red Hat.
83
84 -n A group having the same name as the user being added to the system
85 will be created by default. This option will turn off this Red Hat
86 Linux specific behavior. When this option is used, users by default
87 will be placed in whatever group is specified in
88 /etc/default/useradd. If no default group is defined, group 1 will
89 be used.
90
91 -K, --key KEY=VALUE
92 Overrides /etc/login.defs defaults (UID_MIN, UID_MAX, UMASK,
93 PASS_MAX_DAYS and others).
94
95 Example: -K PASS_MAX_DAYS=-1 can be used when creating system
96 account to turn off password ageing, even though system account has
97 no password at all. Multiple -K options can be specified, e.g.: -K
98 UID_MIN=100
99 -K UID_MAX=499
100
101 Note: -K UID_MIN=10,UID_MAX=499 doesn't work yet.
102
103 -o, --non-unique
104 Allow the creation of a user account with a duplicate (non-unique)
105 UID.
106
107 -p, --password PASSWORD
108 The encrypted password, as returned by crypt(3). The default is to
109 disable the account.
110
111 -r This flag is used to create a system account. That is, a user with a
112 UID lower than the value of UID_MIN defined in /etc/login.defs and
113 whose password does not expire. Note that useradd will not create a
114 home directory for such an user, regardless of the default setting
115 in /etc/login.defs. You have to specify -m option if you want a home
116 directory for a system account to be created. This is an option
117 added by Red Hat
118
119 -s, --shell SHELL
120 The name of the user's login shell. The default is to leave this
121 field blank, which causes the system to select the default login
122 shell.
123
124 -u, --uid UID
125 The numerical value of the user's ID. This value must be unique,
126 unless the -o option is used. The value must be non-negative. The
127 default is to use the smallest ID value greater than 999 and greater
128 than every other user. Values between 0 and 999 are typically
129 reserved for system accounts.
130
131 -Z, --selinux-user SEUSER
132 The SELinux user for the user's login. The default is to leave this
133 field blank, which causes the system to select the default SELinux
134 user.
135
136 Changing the default values
137 When invoked with the -D option, useradd will either display the
138 current default values, or update the default values from the command
139 line. The valid options are
140
141 -b, --base-dir BASE_DIR
142 The initial path prefix for a new user's home directory. The user's
143 name will be affixed to the end of HOME_DIR to create the new
144 directory name if the -d option is not used when creating a new
145 account.
146
147 -e, --expiredate EXPIRE_DATE
148 The date on which the user account is disabled.
149
150 -f, --inactive INACTIVE
151 The number of days after a password has expired before the account
152 will be disabled.
153
154 -g, --gid GROUP
155 The group name or ID for a new user's initial group. The named group
156 must exist, and a numerical group ID must have an existing entry.
157
158 -s, --shell SHELL
159 The name of the new user's login shell. The named program will be
160 used for all future new user accounts.
161
162 If no options are specified, useradd displays the current default
163 values.
164
166 The system administrator is responsible for placing the default user
167 files in the /etc/skel/ directory.
168 This version of useradd was modified by Red Hat to suit Red Hat
169 user/group conventions.
170
172 You may not add a user to a NIS group. This must be performed on the
173 NIS server.
174
175 Similarly, if the username already exists in an external user database
176 such as NIS, useradd will deny the user account creation request.
177
179 /etc/passwd
180 User account information.
181
182 /etc/shadow
183 Secure user account information.
184
185 /etc/group
186 Group account information.
187
188 /etc/gshadow
189 Secure group account information.
190
191 /etc/default/useradd
192 Default values for account creation.
193
194 /etc/skel/
195 Directory containing default files.
196
197 /etc/login.defs
198 Shadow password suite configuration.
199
201 The useradd command exits with the following values:
202
203 0 success
204
205 1 can't update password file
206
207 2 invalid command syntax
208
209 3 invalid argument to option
210
211 4 UID already in use (and no -o)
212
213 6 specified group doesn't exist
214
215 9 username already in use
216
217 10 can't update group file
218
219 12 can't create home directory
220
221 13 can't create mail spool
222
224 chfn(1), chsh(1), passwd(1), crypt(3), groupadd(8), groupdel(8),
225 groupmod(8), login.defs(5), newusers(8), userdel(8), usermod(8).
226
227
228
229System Management Commands 07/30/2006 USERADD(8)