​​ ​

The Apple Support Community will permanently close on November 20, 2026. Starting today, the site will no longer accept new posts and is available in a read-only state.


You can continue to find trusted guidance and support on the official Apple Support site. 


We want to thank the community members who have contributed their time and expertise to help others with their Apple products.


Finding the user password expiration date

On a linux system you can see (and change) the user password expiry information with the command chage. That command is not available on macOS. It seems the replacement is pwpolicy, but I can't get it to work. I've tried various ways like pwpolicy -getglobalpolicy or pwpolicy -u username -getaccountpolicies but nothing is returning useful information. I have tried it with and without sudo.

Posted on Jun 7, 2021 2:59 PM

5 replies

Jun 7, 2021 6:49 PM in response to ashepster

Try

dscl . -read $HOME | /usr/bin/grep -C2 passwordLastSetTime

to get when the password was last set (some parsing of output will be needed)

	<key>passwordLastSetTime</key>
	<real>1616603182.8288069</real>


Try

pwpolicy -getglobalpolicy | grep -C2 policyAttributeExpiresEveryNDays

to get password policyAttributeExpiresEveryNDays

				<key>policyAttributeExpiresEveryNDays</key>
				<integer>90</integer>


Then do the math. Not fun, as you may have to work in seconds and days.

Jun 11, 2021 8:49 AM in response to BobHarris

This basically solved my problem. Here is an ugly line to get the passwordLastSetTime and translate it to a date:


date -r `dscl . -read $HOME | /usr/bin/grep -A1 passwordLastSetTime | grep -o -E '[0-9]+' | head -n 1`


In my corporate environment, pwpolicy -getglobalpolicy doesn't work for me, but the following line does:


pwpolicy getaccountpolicies | grep -A1 \>policyAttributeExpiresEveryNDays


So, a little bit more date calculation and I can figure out when the password will expire.


Thank you!

Jun 7, 2021 6:05 PM in response to ashepster

I just tried the following (without "sudo") on macOS Catalina and it returned the information:

pwpolicy -u test --get-effective-policy


and it returned:

isDisabled=false newPasswordRequired=false


The "man" page for "pwpolicy" does mention these older style options are deprecated and you are supposed to use the "Account Policies" options of the "pwpolicy" command. I did not attempt to test using the command line to modify the settings as I don't want to break anything on my Mac.


Is this your own personal Mac or is it being managed by a school or business that may restrict access to some of these items?


I did find this thread which also mentions these things:

https://apple.stackexchange.com/questions/287217/how-to-force-the-mac-to-not-expire-passwords


This thread has been closed by the system or the community team. You may vote for any posts you find helpful, or search the Community for additional answers.

Finding the user password expiration date

Welcome to Apple Support Community
A forum where Apple customers help each other with their products. Get started with your Apple Account.