Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

The usage of chage Command under linux

2025-01-16 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Servers >

Share

Shulou(Shulou.com)06/01 Report--

This article mainly explains "the usage of chage command under linux". Interested friends may wish to have a look. The method introduced in this paper is simple, fast and practical. Let's let the editor take you to learn the usage of the chage command under linux.

The chage command is used to change the validity period of the account and password.

Grammar

Chage [option] user name

Option

-m: the minimum number of days that the password can be changed. 00:00 means you can change the password at any time.

-M: the maximum number of days that the password remains valid.

-w: the number of days before the user's password expires to receive a warning message in advance.

-E: date on which the account expires. After this day, this account will not be available.

-d: date of the last change.

-I: period of stagnation. If a password has expired these days, then this account will not be available.

-l: enumerates the current settings. It is up to unprivileged users to determine when their passwords or accounts expire.

Example

You can edit / etc/login.defs to set several parameters. Later, the password will be set according to the parameters by default:

PASS_MAX_DAYS 99999

PASS_MIN_DAYS 0

PASS_MIN_LEN 5

PASS_WARN_AGE 7

Of course, you can find the following two parameters to set in / etc/default/useradd:

# useradd defaults file

GROUP=100

HOME=/home

INACTIVE=-1

EXPIRE=

SHELL=/bin/bash

SKEL=/etc/skel

CREATE_MAIL_SPOOL=yes

By modifying the configuration file, it can work for the new users later, while the users who already exist in the system can be configured directly with chage.

My server root account password policy information is as follows:

[root@linuxde ~] # chage-l root

Last password modified: March 12, 2018

Password expiration time: never

Password expiration time: never

Account expiration time: never

The minimum number of days between two password changes: 0

The maximum number of days between two password changes: 99999

Number of days to warn before password expiration: 7

I can change the expiration time of my password with the following command:

[root@linuxde] # chage-M 60 root

[root@linuxde ~] # chage-l root

Last password modified: March 12, 2018

Password expiration date: may 11, 2018

Password expiration time: never

Account expiration time: never

The minimum number of days between two password changes: 0

The maximum number of days between two password changes: 60

Number of days to warn before password expiration: 9

Then set the password expiration time with the following command:

[root@linuxde] # chage-I 5 root

[root@linuxde ~] # chage-l root

Last password modified: March 12, 2018

Password expiration date: may 11, 2018

Password expiration time: may 16, 2018

Account expiration time: never

The minimum number of days between two password changes: 0

The maximum number of days between two password changes: 60

Number of days to warn before password expiration: 9

As can be seen from the above command, 5 days after the password expires, the password automatically expires and the user will not be able to log in to the system.

At this point, I believe you have a deeper understanding of "the use of the chage command under linux". You might as well do it in practice. Here is the website, more related content can enter the relevant channels to inquire, follow us, continue to learn!

Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.

Views: 0

*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

Share To

Servers

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report