• Skip to primary navigation
  • Skip to main content
  • Skip to primary sidebar
  • Skip to footer navigation

The Geek Diary

  • OS
    • Linux
    • CentOS/RHEL
    • Solaris
    • Oracle Linux
    • VCS
  • Interview Questions
  • Database
    • oracle
    • oracle 12c
    • ASM
    • mysql
    • MariaDB
  • DevOps
    • Docker
    • Shell Scripting
  • Big Data
    • Hadoop
    • Cloudera
    • Hortonworks HDP

chage Command Examples in Linux

by admin

chage is a command-line utility in Linux that is used to modify the password aging information for user accounts. Password aging is a security feature that allows you to specify how often users must change their passwords and how long their passwords are valid before they expire.

To modify the password aging information for a user account using chage, you can use the following command syntax:

# chage -M [days] -W [days] [username]

This command will set the maximum number of days that a password is valid to [days] and the number of days before a password must be changed to [days] for the user account [username]. For example, to set the maximum password age to 90 days and the password warning period to 7 days for the user john, you can use the following command:

# chage -M 90 -W 7 john

chage includes many other options and arguments that allow you to customize the password aging information for user accounts. For example, you can use the -d option to specify the date when the password was last changed, or the -I option to specify the number of inactive days after which a user’s password will expire.

For more information on using chage, you can consult the chage documentation or use the chage –help command to view a list of available options and usage examples.

chage Command Examples

1. List password information for the user:

# chage --list username

2. Enable password expiration in 10 days:

# chage --maxdays 10 username

3. Disable password expiration:

# chage --maxdays -1 username

4. Set account expiration date:

# chage --expiredate YYYY-MM-DD username

5. Force user to change password on next log in:

# chage --lastday 0 username

Filed Under: Linux

Some more articles you might also be interested in …

  1. nova Command Examples in Linux
  2. Volume “test_vg/lvol0” is not active locally – Error while running lvcreate
  3. How to Create a tmpfs Filesystem in CentOS/RHEL
  4. What is umask in UNIX/Linux
  5. How to Change the Default Shell In Linux
  6. rbash – Set Restricted shell in Linux
  7. ctrlaltdel: command not found
  8. Beginners Guide to Managing Package Module Streams in CentOS/RHEL 8
  9. How to recover deleted Logical volume (LV) in LVM using vgcfgrestore
  10. How to Recover from a Corrupted or empty /etc/mtab file in CentOS/RHEL 7

You May Also Like

Primary Sidebar

Recent Posts

  • powertop Command Examples in Linux
  • powertop: command not found
  • powerstat: command not found
  • powerstat Command Examples in Linux

© 2023 · The Geek Diary

  • Archives
  • Contact Us
  • Copyright