{"id":73,"date":"2021-09-29T11:44:39","date_gmt":"2021-09-29T11:44:39","guid":{"rendered":"https:\/\/bestdedicatedhosting.in\/blog\/?p=73"},"modified":"2021-11-02T13:11:11","modified_gmt":"2021-11-02T13:11:11","slug":"tweak-password-expiry-using-linux-chage-command","status":"publish","type":"post","link":"https:\/\/bestdedicatedhosting.in\/blog\/tweak-password-expiry-using-linux-chage-command\/","title":{"rendered":"Tweak password expiry using Linux Chage command"},"content":{"rendered":"\n<p><strong>Description<\/strong><\/p>\n\n\n\n<p> The chage command, lets you tweak user password expiry information <\/p>\n\n\n\n<p> Following is its syntax: <\/p>\n\n\n\n<p> <strong><em>chage [options] LOGIN<\/em><\/strong> <\/p>\n\n\n\n<p>And here\u2019s what the man page says about it:<\/p>\n\n\n\n<p><em>The chage command changes the number of days between password changes and the date of the last password change.<\/em><\/p>\n\n\n\n<p><em><br>This information is used by the system to determine when a user must change his\/her password.<\/em><\/p>\n\n\n\n<p>Following are some examples that should give you a good idea on how the chage command works:<\/p>\n\n\n\n<p><strong>To view current password expiry info<\/strong><\/p>\n\n\n\n<p> To view current password expiry date info for a user, use the -l command line option. <\/p>\n\n\n\n<p><strong><em>chage -l [USERNAME]<\/em><\/strong><\/p>\n\n\n\n<p> Here\u2019s an example: <\/p>\n\n\n\n<p><strong><em>chage -l test<\/em><\/strong><\/p>\n\n\n\n<p> And following is the output it produced on my system: <\/p>\n\n\n\n<p><strong><em>Last password change : Oct 16, 2019<br>Password expires : never<br>Password inactive : never<br>Account expires : never<br>Minimum number of days between password change : 0<br>Maximum number of days between password change : 99999<br>Number of days of warning before password expires : 7<\/em><\/strong><\/p>\n\n\n\n<p> So currently, the password is set to expire \u2018never\u2019. <\/p>\n\n\n\n<p><strong>To change password expiry date<\/strong><\/p>\n\n\n\n<p> This you can do using the&nbsp;<strong>-M command<\/strong>&nbsp;line option, which requires you to pass a number (which refers to the maximum number of days during which a password is valid). <\/p>\n\n\n\n<p> For example: <\/p>\n\n\n\n<p><strong><em>chage -M 1000 test<\/em><\/strong><\/p>\n\n\n\n<p>Note that this operation requires root privileges.<\/p>\n\n\n\n<p>Note that you can also use the -m command line option, which is used to set the minimum number of days between password changes.<\/p>\n\n\n\n<p>The&nbsp;<strong>-M<\/strong>&nbsp;option we discussed above sets the maximum number of days during which a password is valid.<\/p>\n\n\n\n<p><strong>To change last password change date<\/strong><\/p>\n\n\n\n<p>You can tweak the last password change date using the -d command line option.<\/p>\n\n\n\n<p>As input, you can either pass a number to this option, or a complete date. Here\u2019s how the man page explains it:<\/p>\n\n\n\n<p><em>-d, \u2013lastday LAST_DAY<br>Set the number of days since January 1st, 1970 when the password<br>was last changed. The date may also be expressed in the format<br>YYYY-MM-DD (or the format more commonly used in your area).<\/em><\/p>\n\n\n\n<p><strong>To warn user before password expires<\/strong><\/p>\n\n\n\n<p>The chage command also lets you set the number of days of warning before a password change is required.<\/p>\n\n\n\n<p>This can be done using the&nbsp;<strong>-W&nbsp;<\/strong>command line option.<\/p>\n\n\n\n<p><em>-W, \u2013warndays WARN_DAYS<br>Set the number of days of warning before a password change is<br>required. The WARN_DAYS option is the number of days prior to the<br>password expiring that a user will be warned his\/her password is<br>about to expire.<\/em><\/p>\n\n\n\n<p>For example:<\/p>\n\n\n\n<p><strong><em>chage -W 10 test<\/em><\/strong><\/p>\n\n\n\n<p>This command will make sure that user gets to see password expiry warning 10 days before the password is set to expire.<\/p>\n\n\n\n<p><strong>To lock an account<\/strong><\/p>\n\n\n\n<p>Use the<strong>&nbsp;-E<\/strong>&nbsp;command line option to lock an account.<\/p>\n\n\n\n<p>The way it accepts input is similar to the&nbsp;<strong>-W<\/strong>&nbsp;option we discussed above.<\/p>\n\n\n\n<p>For your reference, here\u2019s how the man page explains it:<\/p>\n\n\n\n<p><em>-E, \u2013expiredate EXPIRE_DATE<br>Set the date or number of days since January 1, 1970 on which the<br>user\u2019s account will no longer be accessible. The date may also be<br>expressed in the format YYYY-MM-DD (or the format more commonly<br>used in your area). A user whose account is locked must contact the<br>system administrator before being able to use the system again.<\/em><\/p>\n\n\n\n<p><em>P<\/em><em>assing the number -1 as the EXPIRE_DATE will remove an account<br>expiration date.<\/em><\/p>\n\n\n\n<p>For example:<\/p>\n\n\n\n<p><strong><em>chage -E 2019-06-21 test<\/em><\/strong><\/p>\n\n\n\n<p><strong>If chage is used without any option<\/strong><\/p>\n\n\n\n<p>Here\u2019s what happens in this case:<\/p>\n\n\n\n<p><em>If none of the options are selected, chage operates in an interactivefashion, prompting the user with the current values for all of thefields. Enter the new value to change the field, or leave the lineblank to use the current value. The current value is displayed betweena pair of [ ] marks.<\/em><\/p>\n\n\n\n<p>If you are a Linux system admin, or someone who is responsible for user management on Linux machines, this command is worth keeping in your kitty.<\/p>\n\n\n\n<p><br>We hope you\u2019ve found this useful!<\/p>\n","protected":false},"excerpt":{"rendered":"<p>Description The chage command, lets you tweak user password expiry information Following is its syntax: chage [options] LOGIN And here\u2019s what the man page says about it: 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 [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"_eb_attr":"","footnotes":""},"categories":[4],"tags":[],"class_list":["post-73","post","type-post","status-publish","format-standard","hentry","category-linux"],"amp_enabled":true,"_links":{"self":[{"href":"https:\/\/bestdedicatedhosting.in\/blog\/wp-json\/wp\/v2\/posts\/73","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/bestdedicatedhosting.in\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/bestdedicatedhosting.in\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/bestdedicatedhosting.in\/blog\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/bestdedicatedhosting.in\/blog\/wp-json\/wp\/v2\/comments?post=73"}],"version-history":[{"count":1,"href":"https:\/\/bestdedicatedhosting.in\/blog\/wp-json\/wp\/v2\/posts\/73\/revisions"}],"predecessor-version":[{"id":74,"href":"https:\/\/bestdedicatedhosting.in\/blog\/wp-json\/wp\/v2\/posts\/73\/revisions\/74"}],"wp:attachment":[{"href":"https:\/\/bestdedicatedhosting.in\/blog\/wp-json\/wp\/v2\/media?parent=73"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/bestdedicatedhosting.in\/blog\/wp-json\/wp\/v2\/categories?post=73"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/bestdedicatedhosting.in\/blog\/wp-json\/wp\/v2\/tags?post=73"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}