Basics 8 -Linux user and user group management

Implement user account management, work to be done mainly in the following aspects:

  • Add user accounts, delete and modify.
  • User password management.
  • User group management.
  • Add bulk users

/ etc / passwd: Username: Password: user ID: Group ID: Annotated Description: home directory: login Shell

/ Etc / shadow: login: password encryption: Last modified: minimum time interval: maximum time interval: Warning time: No Time: Time: Logo

/ Etc / group: Group name: Password: Group ID: the list of all users

useradd

https://www.cnblogs.com/zknublx/p/9360821.html

format

  useradd [-d home] [-s shell] [-c comment] [-m [-k template]] [-f inactive] [-e expire ] [-p passwd] [-r] name

Description:

  • Options: 

  • -c: make a note of the text, the text notes stored in the remarks column in passwd. 

  •  -d: Specifies the home directory when the user logs in, the system defaults to replace / home / <username>  If this directory does not exist, you can use the -m option, you can create a home directory .

  •   -D: change the default value.
    •   -e: Specifies the account expiration date, date format of MM / DD / YY, such as 06/30/12. The default represents permanent.

        -f: Specifies the number of days after a password has expired, ie close the account. If the account is disabled immediately to 0; -1 if the account is always available. The default value is -1.

        -g: group the user belongs. Value can make the group name can also be a GID. User groups must already exist, the default value of 100, i.e., users.

        -G: specify additional groups the user belongs.

        -m: automatically create the user's login directory.

        -M: Do not automatically create the user's login directory.

        -n: Cancel establish a user name in the name of the group.

        -r: create a system account.

        -s: shell when a user logs used. The default is / bin / bash.

        -u: Specifies the user ID number. This value must be unique in the system. Default 0 to 499 is reserved for system users to use, it must be greater than 499.

    • Use the useradd command to establish the account is actually stored in the / etc / passwd text file.

Example 1

# useradd –d  /home/sam -m sam

This command creates a user sam, where -d and -m option is used to generate a login name, home directory / home / sam sam (/ home is the parent directory of the default user's home directory resides)

Delete Account

userdel

Common option is -r, its role is to delete along with the user's home directory.

# userdel -r sam

 3. Modify Account

usermod

-c, -d, -m, -g, -G, -s, -u以及-o等The significance of these options and useraddcommand options, as you can specify a new value for the resource users.

In addition, some systems can use the options: -l new user name

This option specifies a new account, the original user name soon changed to the new user name

4, user password management

passwd Options Username 

Options can be used:

  • -l Lock password, which disables the account.
  • -u password to unlock.
  • -d the account without a password.
  • -F forced to change password when users log in next time.

If the default user name, then modify the current user's password.

 

When ordinary users to change their passwords, passwd command will check the original password, and then verify that require users to enter a new password twice, enter the same password twice if, then the password assigned to the user; and the super user to specify a password for the user when you do not need to know the original password

 Management system Linux user group

groupadd/groupdel/groupmod

Guess you like

Origin www.cnblogs.com/Spring-Rain/p/12585212.html
Recommended