Linux Command learning: passwd

Source: Internet
Author: User

The passwd command Sets the user's authentication information, including the user's password, password expiration time, and so on. The system administrator can use it to manage the password of the system user. Only the manager can specify the user name, the general user can only change their own password.

Grammar
passwd (option) (parameter)
Options
-D: Remove the password, only the system administrator can use;-f: enforced;-K: Set only after the password expires, the only way to update;-L: Lock the password;-S: Lists information about the password, only the system administrator can use it;-u: Unlock the locked account.
Parameters

User name: The user name for which you want to set the password.

Knowledge Expansion

Files related to user and group account information

Store user information:

/etc/passwd/etc/shadow

Storage Group Information:

/etc/group/etc/gshadow

Analysis of user information files (separated by each item : )

Example: Jack:x:503:504:::/home/jack/:/bin/bashjack//username X//password 503//user ID (0 for root, normal new user starting from 500) 504//Group://Description/ home/jack///Household directory/bin/bash//user default Shell

Group Information file Analysis

Example: jack:$!$:??? : 13801:0:99999:7:*:*: Jack//Group name $!$//encrypted password 13801//The creation date is separated from today 0//password minimum 99999//user password 7//to 7 days Reminder *//disabled days *//expiry days
Example

If an ordinary user executes passwd, you can only modify your own password. If you want to create a password for a new user after creating a new user, use the passwd user name and note that you want to create it with the root user's permissions.

passwd linuxde    // change or create LINUXDE user's password; for user linuxde. New UNIX Password:          // Please enter the password;Retype new UNIX password:   // enter again; passwd // success;

If a normal user wants to change their own password, run passwd directly, such as the current user is linuxde.

passwdfor// change linuxde user's password;(current) UNIX password:   //  Please enter the current password;new UNIX password:         // Please enter your password;Retype unix password:  //  Confirm new password;passwd// change success;
  For example, we let a user cannot change the password, you can use the -l option to lock:
[Email protected] ~]#passwd-L LINUXDE//Lock User Linuxde cannot change password;Locking Password foruser Linuxde.passwd: Success//lock success;[[Email protected]~]#suLinuxde//switch to Linuxde user via su;[Email protected] ~]$passwd      //linuxde to change the password;changing password foruser Linuxde. changing password forLinuxde (current) UNIX password://Enter the current password for the linuxde;passwd: Authentication Token manipulation Error//failed, cannot change password;

Clear Password:

passwd -D linuxde  // clear linuxde user password, for user linuxde. passwd: Success                         // clear success;passwd -S Linuxde    // Query linuxde user password status; Empty password.                         // empty password, that is, no password;
  View the user status: Passwd-s username

User Status flag:
PS: Indicates that the user password has been set.
NL: Indicates that the user account is not a login account.
LK: Indicates that the user has been locked out.
NP: Indicates that the user does not have a password and does not require password authentication when logging in.

Linux Command learning: passwd

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.