Linux users and user password management (+ Detailed examples)

Disclaimer: This article is a blogger original article, follow the CC 4.0 BY-SA copyright agreement, reproduced, please attach the original source link and this statement.
This link: https://blog.csdn.net/bbvjx1314/article/details/102560010

A Linux user and password management

Linux system is a multi-user multi-task time-sharing operating system, a user want to use any system resources, must first apply for an account to the system administrator, and then log in as the account.

Each user account has a unique user name and password for each.

After the user types the correct user name and password when logging in, you can enter the system and their own home directory.

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.

1, add a new user account using the useradd command, its syntax is as follows:

 useradd  选项 用户名

Parameter Description:

  • Options:

    • -c comment Specifies the description of a comment.
    • -d directory Specifies the user's home directory, if this directory does not exist, you can use the -m option, you can create a home directory.
    • -g group of users specify the user group they belong to.
    • -G group of users, user groups, specify additional groups the user belongs.

Example:

(1) add new users itcast

     #    useradd   itcast

2, delete account

# userdel 选项 用户名 

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

Example:

      (2) Delete User zhansan 

         # Userdel zhangsan

       (3) delete the user's home directory and his zhansan 

         #       userdel   -r   zhangsan

3. Modify Account

# usermod 选项 用户名

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

Example:

(4) the user's login Shell maker modified to Kfc, the main directory to / home / z, the user group to developer.

      #    usermod  -s  /bin/ksh  -d   /home/z  –g developer maker 

4, user password management

An important part of user management is user password management. Just create a user account without a password, the system is locked but can not use, you must assign a password before you can use even specify an empty password.

Specify and modify user passwords Shell command passwd. Superuser can specify a password for yourself and other users, ordinary users can only use it to modify their own password. Format command is:

passwd 选项 用户名

Parameter Description:

  • -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.

For example, assume that the current user is the Maker, the following command to change the user's own password

#  passwd 

old passwd :******

New password:*******

Confirm password new  password:*******

If the super user, you can specify any user's password using the following form:

# passwd  super user

New password:*******

Confirm password new  password:*******

If the user wants to use an empty password, execute the following command in the form:

# passwd -d 用户名

If you want to lock a user, you can not log in, perform the following command in the form:

# passwd -l 用户名

If you want to unlock a user, execute the following command in the form:

# passwd -u 用户名

Example:

(5) Clear node01 user password.

 passwd  -d  node01

(6) The user node01 locked.

 passwd  -l  node01

(7) the user node01 unlocked.

 passwd  -u  node01

Guess you like

Origin blog.csdn.net/bbvjx1314/article/details/102560010