Thursday, August 2, 2018

How to check the lock status of any user account and change the Password policy in Linux


1. To check User lock status

[root@oracle ~]# chage -l mysql
Last password change                                    : Jul 26, 2018
Password expires                                        : never
Password inactive                                       : never
Account expires                                         : never
Minimum number of days between password change          : -1
Maximum number of days between password change          : -1
Number of days of warning before password expires       : -1

Find more details by using below command

[root@oracle ~]# passwd --help
Usage: passwd [OPTION...] <accountName>
  -k, --keep-tokens       keep non-expired authentication tokens
  -d, --delete            delete the password for the named account (root only)
  -l, --lock              lock the password for the named account (root only)
  -u, --unlock            unlock the password for the named account (root only)
  -e, --expire            expire the password for the named account (root only)
  -f, --force             force operation
  -x, --maximum=DAYS      maximum password lifetime (root only)
  -n, --minimum=DAYS      minimum password lifetime (root only)
  -w, --warning=DAYS      number of days warning users receives before password expiration (root only)
  -i, --inactive=DAYS     number of days after password expiration when an account becomes disabled (root only)
  -S, --status            report password status on the named account (root only)
  --stdin                 read new tokens from stdin (root only)

Help options:
  -?, --help              Show this help message
  --usage                 Display brief usage message

2. Change Password Policy using below command.

[root@oracle ~]# passwd mysql --minimum=0 --maximum=99999 --warning=7
Adjusting aging data for user mysql.
passwd: Success

[root@oracle ~]# chage -l mysql
Last password change                                    : Jul 26, 2018
Password expires                                        : never
Password inactive                                       : never
Account expires                                         : never
Minimum number of days between password change          : 0
Maximum number of days between password change          : 99999

Number of days of warning before password expires       : 7

No comments:

Post a Comment