1USERMOD(8)                System Management Commands                USERMOD(8)
2
3
4

NAME

6       usermod - modify a user account
7

SYNOPSIS

9       usermod [options] LOGIN
10

DESCRIPTION

12       The usermod command modifies the system account files to reflect the
13       changes that are specified on the command line.
14

OPTIONS

16       The options which apply to the usermod command are:
17
18       -a, --append
19           Add the user to the supplementary group(s). Use only with the -G
20           option.
21
22       -b, --badnames
23           Allow names that do not conform to standards.
24
25       -c, --comment COMMENT
26           The new value of the user's password file comment field. It is
27           normally modified using the chfn(1) utility.
28
29       -d, --home HOME_DIR
30           The user's new login directory.
31
32           If the -m option is given, the contents of the current home
33           directory will be moved to the new home directory, which is created
34           if it does not already exist. If the current home directory does
35           not exist the new home directory will not be created.
36
37       -e, --expiredate EXPIRE_DATE
38           The date on which the user account will be disabled. The date is
39           specified in the format YYYY-MM-DD.
40
41           An empty EXPIRE_DATE argument will disable the expiration of the
42           account.
43
44           This option requires a /etc/shadow file. A /etc/shadow entry will
45           be created if there were none.
46
47       -f, --inactive INACTIVE
48           The number of days after a password expires until the account is
49           permanently disabled.
50
51           A value of 0 disables the account as soon as the password has
52           expired, and a value of -1 disables the feature.
53
54           This option requires a /etc/shadow file. A /etc/shadow entry will
55           be created if there were none.
56
57       -g, --gid GROUP
58           The group name or number of the user's new initial login group. The
59           group must exist.
60
61           Any file from the user's home directory owned by the previous
62           primary group of the user will be owned by this new group.
63
64           The group ownership of files outside of the user's home directory
65           must be fixed manually.
66
67           The change of the group ownership of files inside of the user's
68           home directory is also not done if the home dir owner uid is
69           different from the current or new user id. This is a safety measure
70           for special home directories such as /.
71
72       -G, --groups GROUP1[,GROUP2,...[,GROUPN]]]
73           A list of supplementary groups which the user is also a member of.
74           Each group is separated from the next by a comma, with no
75           intervening whitespace. The groups are subject to the same
76           restrictions as the group given with the -g option.
77
78           If the user is currently a member of a group which is not listed,
79           the user will be removed from the group. This behaviour can be
80           changed via the -a option, which appends the user to the current
81           supplementary group list.
82
83       -l, --login NEW_LOGIN
84           The name of the user will be changed from LOGIN to NEW_LOGIN.
85           Nothing else is changed. In particular, the user's home directory
86           or mail spool should probably be renamed manually to reflect the
87           new login name.
88
89       -L, --lock
90           Lock a user's password. This puts a '!' in front of the encrypted
91           password, effectively disabling the password. You can't use this
92           option with -p or -U.
93
94           Note: if you wish to lock the account (not only access with a
95           password), you should also set the EXPIRE_DATE to 1.
96
97       -m, --move-home
98           Move the content of the user's home directory to the new location.
99           If the current home directory does not exist the new home directory
100           will not be created.
101
102           This option is only valid in combination with the -d (or --home)
103           option.
104
105           usermod will try to adapt the ownership of the files and to copy
106           the modes, ACL and extended attributes, but manual changes might be
107           needed afterwards.
108
109       -o, --non-unique
110           When used with the -u option, this option allows to change the user
111           ID to a non-unique value.
112
113       -p, --password PASSWORD
114           The encrypted password, as returned by crypt(3).
115
116           Note: This option is not recommended because the password (or
117           encrypted password) will be visible by users listing the processes.
118
119           You should make sure the password respects the system's password
120           policy.
121
122       -r, --remove
123           Remove the user from named supplementary group(s). Use only with
124           the -G option.
125
126       -R, --root CHROOT_DIR
127           Apply changes in the CHROOT_DIR directory and use the configuration
128           files from the CHROOT_DIR directory.
129
130       -P, --prefix PREFIX_DIR
131           Apply changes in the PREFIX_DIR directory and use the configuration
132           files from the PREFIX_DIR directory. This option does not chroot
133           and is intended for preparing a cross-compilation target. Some
134           limitations: NIS and LDAP users/groups are not verified. PAM
135           authentication is using the host files. No SELINUX support.
136
137       -s, --shell SHELL
138           The path of the user's new login shell. Setting this field to blank
139           causes the system to select the default login shell.
140
141       -u, --uid UID
142           The new numerical value of the user's ID.
143
144           This value must be unique, unless the -o option is used. The value
145           must be non-negative.
146
147           The user's mailbox, and any files which the user owns and which are
148           located in the user's home directory will have the file user ID
149           changed automatically.
150
151           The ownership of files outside of the user's home directory must be
152           fixed manually.
153
154           The change of the user ownership of files inside of the user's home
155           directory is also not done if the home dir owner uid is different
156           from the current or new user id. This is a safety measure for
157           special home directories such as /.
158
159           No checks will be performed with regard to the UID_MIN, UID_MAX,
160           SYS_UID_MIN, or SYS_UID_MAX from /etc/login.defs.
161
162       -U, --unlock
163           Unlock a user's password. This removes the '!' in front of the
164           encrypted password. You can't use this option with -p or -L.
165
166           Note: if you wish to unlock the account (not only access with a
167           password), you should also set the EXPIRE_DATE (for example to
168           99999, or to the EXPIRE value from /etc/default/useradd).
169
170       -v, --add-subuids FIRST-LAST
171           Add a range of subordinate uids to the user's account.
172
173           This option may be specified multiple times to add multiple ranges
174           to a users account.
175
176           No checks will be performed with regard to SUB_UID_MIN,
177           SUB_UID_MAX, or SUB_UID_COUNT from /etc/login.defs.
178
179       -V, --del-subuids FIRST-LAST
180           Remove a range of subordinate uids from the user's account.
181
182           This option may be specified multiple times to remove multiple
183           ranges to a users account. When both --del-subuids and
184           --add-subuids are specified, the removal of all subordinate uid
185           ranges happens before any subordinate uid range is added.
186
187           No checks will be performed with regard to SUB_UID_MIN,
188           SUB_UID_MAX, or SUB_UID_COUNT from /etc/login.defs.
189
190       -w, --add-subgids FIRST-LAST
191           Add a range of subordinate gids to the user's account.
192
193           This option may be specified multiple times to add multiple ranges
194           to a users account.
195
196           No checks will be performed with regard to SUB_GID_MIN,
197           SUB_GID_MAX, or SUB_GID_COUNT from /etc/login.defs.
198
199       -W, --del-subgids FIRST-LAST
200           Remove a range of subordinate gids from the user's account.
201
202           This option may be specified multiple times to remove multiple
203           ranges to a users account. When both --del-subgids and
204           --add-subgids are specified, the removal of all subordinate gid
205           ranges happens before any subordinate gid range is added.
206
207           No checks will be performed with regard to SUB_GID_MIN,
208           SUB_GID_MAX, or SUB_GID_COUNT from /etc/login.defs.
209
210       -Z, --selinux-user SEUSER
211           The new SELinux user for the user's login.
212
213           A blank SEUSER will remove the SELinux user mapping for user LOGIN
214           (if any).
215

CAVEATS

217       You must make certain that the named user is not executing any
218       processes when this command is being executed if the user's numerical
219       user ID, the user's name, or the user's home directory is being
220       changed.  usermod checks this on Linux. On other platforms it only uses
221       utmp to check if the user is logged in.
222
223       You must change the owner of any crontab files or at jobs manually.
224
225       You must make any changes involving NIS on the NIS server.
226

CONFIGURATION

228       The following configuration variables in /etc/login.defs change the
229       behavior of this tool:
230
231       LASTLOG_UID_MAX (number)
232           Highest user ID number for which the lastlog entries should be
233           updated. As higher user IDs are usually tracked by remote user
234           identity and authentication services there is no need to create a
235           huge sparse lastlog file for them.
236
237           No LASTLOG_UID_MAX option present in the configuration means that
238           there is no user ID limit for writing lastlog entries.
239
240       MAIL_DIR (string)
241           The mail spool directory. This is needed to manipulate the mailbox
242           when its corresponding user account is modified or deleted. If not
243           specified, a compile-time default is used. The parameter
244           CREATE_MAIL_SPOOL in /etc/default/useradd determines whether the
245           mail spool should be created.
246
247       MAIL_FILE (string)
248           Defines the location of the users mail spool files relatively to
249           their home directory.
250
251       The MAIL_DIR and MAIL_FILE variables are used by useradd, usermod, and
252       userdel to create, move, or delete the user's mail spool.
253
254       If MAIL_CHECK_ENAB is set to yes, they are also used to define the MAIL
255       environment variable.
256
257       MAX_MEMBERS_PER_GROUP (number)
258           Maximum members per group entry. When the maximum is reached, a new
259           group entry (line) is started in /etc/group (with the same name,
260           same password, and same GID).
261
262           The default value is 0, meaning that there are no limits in the
263           number of members in a group.
264
265           This feature (split group) permits to limit the length of lines in
266           the group file. This is useful to make sure that lines for NIS
267           groups are not larger than 1024 characters.
268
269           If you need to enforce such limit, you can use 25.
270
271           Note: split groups may not be supported by all tools (even in the
272           Shadow toolsuite). You should not use this variable unless you
273           really need it.
274
275       SUB_GID_MIN (number), SUB_GID_MAX (number), SUB_GID_COUNT (number)
276           If /etc/subuid exists, the commands useradd and newusers (unless
277           the user already have subordinate group IDs) allocate SUB_GID_COUNT
278           unused group IDs from the range SUB_GID_MIN to SUB_GID_MAX for each
279           new user.
280
281           The default values for SUB_GID_MIN, SUB_GID_MAX, SUB_GID_COUNT are
282           respectively 100000, 600100000 and 65536.
283
284       SUB_UID_MIN (number), SUB_UID_MAX (number), SUB_UID_COUNT (number)
285           If /etc/subuid exists, the commands useradd and newusers (unless
286           the user already have subordinate user IDs) allocate SUB_UID_COUNT
287           unused user IDs from the range SUB_UID_MIN to SUB_UID_MAX for each
288           new user.
289
290           The default values for SUB_UID_MIN, SUB_UID_MAX, SUB_UID_COUNT are
291           respectively 100000, 600100000 and 65536.
292

FILES

294       /etc/group
295           Group account information.
296
297       /etc/gshadow
298           Secure group account information.
299
300       /etc/login.defs
301           Shadow password suite configuration.
302
303       /etc/passwd
304           User account information.
305
306       /etc/shadow
307           Secure user account information.
308
309       /etc/subgid
310           Per user subordinate group IDs.
311
312       /etc/subuid
313           Per user subordinate user IDs.
314

SEE ALSO

316       chfn(1), chsh(1), passwd(1), crypt(3), gpasswd(8), groupadd(8),
317       groupdel(8), groupmod(8), login.defs(5), subgid(5), subuid(5),
318       useradd(8), userdel(8).
319
320
321
322shadow-utils 4.11.1               02/10/2022                        USERMOD(8)
Impressum