Which command is used to change the user password expiration information?

Linux is one of the most popular operating systems for servers, and Linux also offers a great desktop OS. However, there are some things that can be difficult to understand when you’re new to Linux. One example is passwords expiry – what does this mean? How do you change the expiration date for your password in Linux? How do you change user password, UNIX password, and use the passwd command?

If you’re not in IT services, or sidebar not a techie, the Linux change password command and coding the expiry date can all seem overwhelming. If you can barely remember your username, setting expiration dates is the last thing on your mind. But, Linux change account passwords settings allow you to keep yours and others users in Linux secure. By using the root user and the user root password and the command line chage.

In this article, we’ll answer these questions and more. Keep reading to learn more.

Table of Contents

  • Change expiry and enter new UNIX password in Linux
  • Listing password aging for user
  • Change the number of days to expire
  • Change the password to never expire
  • Change account expiry to specific date

Change expiry and enter new UNIX password in Linux

Which command is used to change the user password expiration information?

“chage” is the command to list & change the user password aging information for the change password user account. Use the passwd command chage to change the number of days between user password expiry and the current date. It’s easy to access the chage command line to utilize it in Linux. Think of it as the account password change button in the shadow file.

The change the password notification will be sent and passwords will be set to expire on the date you specify. The valid range is from 0 (today) up until 90 years in future, and if it’s less than today then a warning message pops-up again reminding that the change user password in Linux has already expired.

Here’s a real quick rundown on how to show the expiration date of a particular linux user account. Here are the different settings:

  • Listing password aging for user and user accounts
  • Change the number of days to expire for the alert to change user password on the account
  • Change the password to never expire so you have control and can change your own password
  • Change account expiry to a specific date to change the password

Let’s explore how to use this command in the terminal!

Listing password aging for user

Which command is used to change the user password expiration information?

chage command with option -l shows the expiry details of a specific user. This sudo command allows users to plan on a new password the next time the user’s password is set to expire.

In this example, the user’s last new password change was on Dec 25th 2017 and it expires in 90 days. The user will be notified within login 7 days before expiry.

 [root@centos01 ~]# chage -l demouser
 Last password change : Dec 25, 2017
 Password expires : never
 Password inactive : never
 Account expires : never
 Minimum number of days between password change : 0
 Maximum number of days between password change : 90
 Number of days of warning before password expires : 7
 [root@centos01 ~]#

Change the number of days to expire

Which command is used to change the user password expiration information?

Use -M option and provide the number of days to expiry. You can see in the example below, the user can change to their new password the next time it’s required, in 180 days.

Some of the reasons you might want to change the number of days to expiry are to enforce a more stringent new password policy, to force the user into changing their passwords on time, to take over the account with the sysadmin, doubling back to the root user, etc.

[root@centos01 ~]# chage -M 120 demouser
 [root@centos01 ~]# chage -l demouser
 Last password change : Jan 25, 2018
 Password expires : May 25, 2018
 Password inactive : never
 Account expires : never
 Minimum number of days between password change : 0
 Maximum number of days between password change : 120
 Number of days of warning before password expires : 7
 [root@centos01 ~]#

Change the password to never expire

Which command is used to change the user password expiration information?

You can use chage to make the user’s password never expire with the below options. This sets the user password/UNIX password to never expire. Some reasons why you may want to switch to the password never expiring are if you’re sharing the account with a co-worker or if it is for your personal use.

This way neither one of you will be left in the lurch if you forget your password. You simply manage the root access passwd and type passwd command to change it yourself when needed.

You can also set the number of days to change and how many warnings you want before it expires with chage. Be careful to keep track of your passwords and to set the correct number of days for your user password.

This command will create an expiration date that is in never part, so it won’t expire at all: PASSWORD_MAXAGE=never chage -M 0 username . A maximum password age can be specified as a time span with units such (years) or (-m):

Option one: -M199200 — this will set the Linux password to never expire and then change user password expires attribute from “never” (default)to NEVER (-1201). The screen looks like this.

 [root@centos01 ~]# chage -m 0 -M 99999 -I -1 -E -1 demouser
 [root@centos01 ~]# chage -l demouser
 Last password change : Jan 25, 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
 [root@centos01 ~]#

Change account expiry to specific date

Which command is used to change the user password expiration information?

You can set the user password commands or UNIX password and the entire account distribution to expire on a specific date or +N number of days from the current date.

Some of the reasons this is helpful are when you are testing a potential new employee and whether the information they gave is accurate, and want the user password to expire after the test window is done. When the file is set to expire, or when an employee is terminated, etc shadow.

All of this is done with one command: ot@centos01 ~] #chage -E +21 demouser (type in your password and answer y)[/size][/li][line break=true

Which command can be used to change the user password?

The passwd command sets and changes passwords for users. Use this command to change your own password or another user's password. You can also use the passwd command to change the full name (gecos) associated with your login name and the shell you use as an interface to the operating system.

Which Linux command is used to expire password?

Password expiry Use the chage command to set the expiry date for an account. This setting defines a given date, after which a user account is locked and inaccessible. You can do this with the --expiredate ( -E for short) option.

Which command is used to list and modify password expiration information for user accounts in Linux?

Type chage -l userName command to display password expiration information for Linux user account. The -l option passed to the change show account aging information.

How to check user password expiry in Linux?

The 'chage' command can be used to see the password expiration date for a specific user, but it can't be used to query this information for several users at once.