Linux User forces initial password change at first logon _linux shell

Source: Internet
Author: User

The following describes how to force users to change their passwords the next time they log on.

Each user account under Linux is associated with the various configuration and information associated with the password. For example, it remembers the date of the last password change, the minimum/maximum number of days between changes in the password, and when the current password expires, and so on.

A command-line tool named Chage can access and adjust the configuration associated with a password expiration failure. You can use this tool to force any user to change their password at the next logon.

To view password expiration information for a user (such as Alice), run the following command. Please note that root user permissions are required only if you are checking the password expiration information for any other user other than yourself.

$ sudo chage-l Alice

Force user to change password

If you want to force users to change their passwords, use this command below.

$ sudo chage-d0 <user-name>

Initially, the "-D <N>" option should be set to the "Expiration date" of the password (the number of days since the password was last changed from January 1, 1970). Therefore, "-d0" indicates that the password was changed on January 1, 1970, which actually makes the current password expire, allowing the password to be changed at the next logon.

Another way to expire the current password is through the passwd command.

$ sudo passwd-e <user-name>

The above command has the same effect as "chage-d0", allowing the user's current password to expire immediately.

Now, once again, check the user's password information, and you will see:

When you log in again, the system will ask you to change your password. You need to confirm the current password multiple times before changing the password.

To set a more comprehensive password policy (such as password complexity and prevent reuse), you can use Pam (what about Pam?). Here is the first to leave a thought, then the article will have the relevant content updates.

How to force Linux users to change their initial password at the first logon I believe that we should have an in-depth understanding of this article, I hope that everyone has harvested it.

Related Article

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.