Use of usermod in user and group management on the command line interface, command line usermod

Source: Internet
Author: User

Use of usermod in user and group management on the command line interface, command line usermod

After adding a user using useradd, you need to use the usermod command to make some modifications.

Function Description: Modify the information of a user account.

Syntax: usermod [-L | U] [-c <remarks>] [-d <logon directory>] [-e <validity period>] [-f <buffer days>] [- g <group>] [-G <group>]

[-L <Account Name>] [-s <specified logon shell>] [-u <New uid>] username

Note: usermod can be used to modify user account settings.

Parameters:

-C <remarks> modify the remarks of the user account.

-D <full path of the home directory> modify the directory when the user logs in.

-E <deadline> modifies the Account expiration time. Format: YYYY-MM-DD

-F <buffer days> Number of days after the password expires until the account permanently expires

-G <group>: Modify the group to which the user belongs.

-G <group> modify the additional group to which the user belongs.

-L <Account Name> modify the user account name.

-L lock the user password to make it invalid.

-S: Modify the shell used after user login.

-U: Modify the user ID.

-U unlocks the password.

Note: usermod does not allow you to change the user account in use in the system. When usermod is used to change UID, you must confirm that the user is not in the system
.

It is generally not recommended to modify the user name and user ID, because it may cause trouble for changing the identity of the file owner. For example, before a change
The user name and UID of a file named test are modified. After the user name and UID are modified, the information about the file owner and Its group is not synchronized. That is to say
The user cannot control the test file.

Example:

# Useradd waston Add User waston

After the row is successfully added, add the row in/etc/passwd.

Waston: x: 4036: 4038:/home/waston:/bin/bash

# Groupadd super Add a group

After the row is successfully added, add the row in/etc/group.

Super: x: 4037:

# Usermod-u 4037 waston change the UID of user waston to 4037, that is, the super group

After the change is successful, the line is updated in/etc/passwd.

Waston: x: 4037: 4038:/home/waston:/bin/bash


The usage of other parameters is similar. Not detailed

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.