Usermod (8) System Administration command Usermod (8)
Name
Usermod-Modify a user account
Big
usermod [Options] Login
Stroke
Usermod Modify the System account file and the related changes specified on the command line.
Choose
The options that Usermod can accept are:
*************************************************************************************************************** **********
-U,--uiduid #改变用户的ID
A new value for the user ID.
This value must be unique unless the-o option is used and must be non-negative.
User's mailbox, the master ID of the file belonging to this user in the user's home directory will also be changed automatically. File ownership outside of
user home directories must be repaired manually.
does not uid_min in/etc/login.defs, Uid_max, Sys_ Uid_min and
sys_uid_max for inspection.
Note: If you want to unlock your account (not just access with a password), you should also set
Expire_date (for example, set to 99999, or/etc/default/useradd in the
EXPIRE value).
-O,--non-unique
When you use the-u option, you can change the user ID to a non-unique value.
g,--gidgroup #改变
the group name or number designator of the new initial login group for the user. This group must exist. In the
user home directory, the files that belong to the original primary group are forwarded to the new group. Groups that belong to a file other than the
home directory must be manually modified.
-A,--append #添加
add a user to an additional group. Can only be used with the-G option.
g,--groupsgroup1[,group2,... [, GROUPN]]
users also belong to the list of additional groups. Groups are separated by commas with no spaces. These groups are subject to the same limitations as the groups given in the
G option.
If the user is currently a member of a group, and the group is not listed here, the user will be removed from that group. This behavior can be modified by the
-a option, which appends the user to the list of attached groups given.
*************************************************************************************************************** ************
-D,--homehome_dir
The user's new login directory.
If you give the-m
option, the contents of the current home directory will be moved to the new home directory, and if it does not exist, it is created.
-M,--move-home
Move the user's home directory to a new location.
This option is only valid if used in combination with the-D (or--home) option.
Usermod will overwrite the owner of the file and copy the schema, ACL
and extended properties, but may also need to be modified manually later.
*************************************************************************************************************** ************
-E,--expiredateexpire_date
The date on which the user account will be disabled. The date is specified in the YYYY-MM-DD format.
The empty expire_date parameter disables account expiration.
This option requires a/etc/passwd file. If not, a/etc/shadow will be created
Project.
-F,--inactiveinactive
The number of days before the account is completely disabled after the password expires.
0 indicates that the account is disabled immediately when the password expires, and 1 indicates that this function is not used.
This option requires a/etc/passwd file. If not, a/etc/shadow will be created
Project.
* *****
-L,--lock
Locks the user's password. This will place a "!" before the user encrypts the password, which can be quickly disabled. You can and
Use this option with-P or-U.
Note: If you want to lock your account (not just through a password), you also need to set
Expire_date is 1.
-U,--unlock
Unlocks the user's password. This will remove the encrypted password before the "!". You can use this option with the-P or
-L in conjunction with.
^
L
L
*************************************************************************************************************** ********
-L,--loginnew_login
The user's name will be changed from LOGIN to
New_login. will not change anything else. In particular, the user's home directory name and Mail pool also need to be manually modified to correspond to the new login name.
-C,--commentcomment
The new value of the Comment field in the user password file. It is usually modified using the CHFN (1) tool.
-P,--passwordpassword
The password that has been encrypted, as crypt (3) returns.
Note
The password will be written to the local/etc/passwd or/etc/shadow
File. This may be different from your machine, depending on the PAM
Configuration is determined by the password database configuration.
You should ensure that the password complies with the system's password policy.
-R,--rootchroot_dir
Apply changes in the Chroot_dir directory and use the configuration
Files from the Chroot_dir directory.
-S,--shellshell
The name of the user's new login shell. Setting this field to blank causes the system to select the default login
Shell
*************************************************************************************************************** ****
-V,--add-subuids first-last Add range of subordinate UIDs
-V,--del-subuids first-last Remvoe range of subordinate UIDs
-W,--add-subgids first-last Add range of subordinate Gids
-W,--del-subgids First-last Remvoe range of subordinate GID
-V,--add-sub-uids first-last
ADD a range of subordinate UIDs to the users account.
This option is specified multiple times to add multiple ranges
To a users account.
No checks'll be performed with regard to Sub_uid_min,
Sub_uid_max, or Sub_uid_count from/etc/login.defs.
-V,--del-sub-uids first-last
Remove a range of subordinate UIDs from the users account.
This option is specified multiple times to remove multiple
Ranges to a users account. When both--del-sub-uids and
--add-sub-uids is specified remove of all subordinate UID ranges
Happens before any subordinate UID ranges is added.
No checks'll be performed with regard to Sub_uid_min,
Sub_uid_max, or Sub_uid_count from/etc/login.defs.
-W,--add-sub-gids First-last
ADD a range of subordinate Gids to the users account.
This option is specified multiple times to add multiple ranges
To a users account.
No checks'll be performed with regard to Sub_gid_min,
Sub_gid_max, or Sub_gid_count from/etc/login.defs.
-W,--del-sub-gids First-last
Remove a range of subordinate Gids from the users account.
This option is specified multiple times to remove multiple
Ranges to a users account. When both--del-sub-gids and
--add-sub-gids is specified remove of all subordinate GID ranges
Happens before any subordinate GID ranges is added.
No checks'll be performed with regard to Sub_gid_min,
Sub_gid_max, or Sub_gid_count from/etc/login.defs.
*************************************************************************************************************** ***
-Z,--selinux-userseuser
User logged on to the SELinux user.
An empty seuser will remove the SELinux user mappings (if any) of the user LOGIN.
Caveats
If you want to change the user's number
ID, user name, or home directory, you need to ensure that the user does not perform any processes when the command is allowed. Usermod
will be checked on Linux, but on other platforms, it is only based on utmp
Check to see if the user is logged in.
You must manually change the crontab file or the owner of the at job.
You must change the NIS-related content on the NIS server.
With
There are configuration variables in/etc/login.defs that can be used to change the behavior of this tool:
Mail_dir (String)
The mailbox directory. When modifying or deleting a user account, the mailbox needs to be processed, and if not specified, the default value specified at compile time is used.
Mail_file (String)
Defines the location of the user mailbox file (relative to the home directory).
Mail_dir and Mail_file variables by Useradd,usermod and Userdel
Used to create, move, or delete user mailboxes.
Max_members_per_group (number)
The maximum number of members for each group entry. When the maximum value is reached, the/etc/group
Start a new entry (line) (use the same name, same password, same GID).
The default value is 0, which means there is no limit on the number of members in the group.
This feature (split group) allows you to limit the length of the group file. This is for ensuring that the NIS group has a longer row than
1024 characters.
If you want to enforce this restriction, you can use 25.
Note: Split groups may not be supported by all tools (even in Shadow
Tool Set). You should not use this variable unless you really need it.
Text
/etc/group
Group account information.
/etc/gshadow
Security group account information.
/etc/login.defs
Shadow Cipher Suite configuration.
/etc/passwd
User account information.
/etc/shadow
Secure user account information.
Parameter
CHFN (1), Chsh (1), passwd (1), Crypt (3), GPASSWD (8), Groupadd (8),
Groupdel (8), Groupmod (8), Login.defs (5), Useradd (8), Userdel (8).
Shadow-utils 4.1.5.1 2014-02-17 usermod (8)
Linux--Usermod