What is the syntax of chage command in Linux

WBOY
Release: 2023-05-15 17:25:12
forward
1422 people have browsed it

Linux chage command introduction:

The chage command is used for password effectiveness management. It is used to modify the validity period of the account and password. It can modify the validity period of account and password. The description of the chage command is as follows:

the chage command changes the number of days between password changes and the date of the last password change. this information is used by the system to determine when a user must change his /her password

Command syntax:

chage [options] user

Command parameters:

Parameter

Description

-d

The specified password was last modified Date

-e

The date the password expires. After this day, this account will be unavailable. 0 means it will expire immediately, -1 means it will never expire.

-h

Display help information and exit

-i

The number of days to lock the account after the password expires

-l

List the validity period of users and passwords

-m

The password is OK Minimum number of days to change. A value of zero means the password can be changed at any time.

-m

Maximum number of days a password remains valid.

-w

The number of days to receive a warning message before the password expires.

Usage example:

1: View the help information of the chage command

[root@db-server ~]# man chage
[root@db-server ~]# info chage
[root@db-server ~]# chage -h
usage: chage [options] user

options:

-d, --lastday last_day set last password change to last_day
-e, --expiredate expire_date set account expiration date to expire_date
-h, - -help display this help message and exit
-i, --inactive inactive set password inactive after expiration
to inactive
-l, --list show account aging information
-m, --mindays min_days set minimum number of days before password
change to min_days
-m, --maxdays max_days set maximim number of days before password
change to max_days
-w, --warndays warn_days set expiration warning days to warn_days

2: Check the validity period of mysql user and password

[root@db-server ~]# chage -l mysql
last password change: mar 26, 2015
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
[root@db-server ~]

#3: Set the mysql user password to expire after 60 days, and the password can be changed after at least 7 days. You will start receiving warning messages 7 days before the password expires.

[root@db-server ~]# chage -m 60 -m 7 -w 7 mysql
you have new mail in /var/spool/mail/root
[root@db- server ~]# chage -l mysql
last password change : mar 26, 2015
password expires : may 25, 2015
password inactive : never
account expires : never
minimum number of days between password change : 7
maximum number of days between password change : 60
number of days of warning before password expires : 7
[root@db-server ~]
#clip_image001

4: Force new users to change their password when logging in for the first time

[root@db-server home]# useradd test
[root@db-server home]# passwd test
changing password for user test.
new unix password:
retype new unix password:
passwd: all authentication tokens updated successfully.
[root@db-server home]# chage -d 0 test
you have new mail in /var/spool/mail/root
[root@db-server home]# chage -l test
last password change : password must be changed
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

The following is an introduction to the linux chage command

Function:Modify the validity period of the account and password

Usage: chage[-l][-m mindays][-m maxdays][-i inactive][-e expiredate][-w warndays][-d lastdays]username

Parameters:

-l: List the user and the validity period of the password
-m: The minimum number of days to change the password
-m: The maximum number of days to change the password Number of days
-i: The number of days to lock the account after the password expires
-d: Specify the date when the password was last modified
-e: Validity period, 0 means immediate expiration, -1 means never expires
- w: Number of days to start warning before password expiration

The above is the detailed content of What is the syntax of chage command in Linux. For more information, please follow other related articles on the PHP Chinese website!

Related labels:
source:yisu.com
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template
About us Disclaimer Sitemap
php.cn:Public welfare online PHP training,Help PHP learners grow quickly!