


What is the syntax of chage command in Linux
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!

Hot AI Tools

Undresser.AI Undress
AI-powered app for creating realistic nude photos

AI Clothes Remover
Online AI tool for removing clothes from photos.

Undress AI Tool
Undress images for free

Clothoff.io
AI clothes remover

Video Face Swap
Swap faces in any video effortlessly with our completely free AI face swap tool!

Hot Article

Hot Tools

Notepad++7.3.1
Easy-to-use and free code editor

SublimeText3 Chinese version
Chinese version, very easy to use

Zend Studio 13.0.1
Powerful PHP integrated development environment

Dreamweaver CS6
Visual web development tools

SublimeText3 Mac version
God-level code editing software (SublimeText3)

Hot Topics











The five basic components of the Linux system are: 1. Kernel, 2. System library, 3. System utilities, 4. Graphical user interface, 5. Applications. The kernel manages hardware resources, the system library provides precompiled functions, system utilities are used for system management, the GUI provides visual interaction, and applications use these components to implement functions.

VS Code One-step/Next step shortcut key usage: One-step (backward): Windows/Linux: Ctrl ←; macOS: Cmd ←Next step (forward): Windows/Linux: Ctrl →; macOS: Cmd →

To view the Git repository address, perform the following steps: 1. Open the command line and navigate to the repository directory; 2. Run the "git remote -v" command; 3. View the repository name in the output and its corresponding address.

Although Notepad cannot run Java code directly, it can be achieved by using other tools: using the command line compiler (javac) to generate a bytecode file (filename.class). Use the Java interpreter (java) to interpret bytecode, execute the code, and output the result.

There are six ways to run code in Sublime: through hotkeys, menus, build systems, command lines, set default build systems, and custom build commands, and run individual files/projects by right-clicking on projects/files. The build system availability depends on the installation of Sublime Text.

The main uses of Linux include: 1. Server operating system, 2. Embedded system, 3. Desktop operating system, 4. Development and testing environment. Linux excels in these areas, providing stability, security and efficient development tools.

Installing Git software includes the following steps: Download the installation package and run the installation package to verify the installation configuration Git installation Git Bash (Windows only)

To install Laravel, follow these steps in sequence: Install Composer (for macOS/Linux and Windows) Install Laravel Installer Create a new project Start Service Access Application (URL: http://127.0.0.1:8000) Set up the database connection (if required)
