Super User is a question and answer site for computer enthusiasts and power users. It's 100% free, no registration required.

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

If I know my password is foobar how can I use dscl to verify this on my machine? Of course the password is encrypted (Password: ********) in the output of dscl . -read /Users/myuser.

It's fine if I must use another utility to achieve this, by the way.

share|improve this question
up vote 1 down vote accepted

OS X doesn't store your password, so you cannot read it from some file or database.

What you can do is perform a log-in of some kind, e.g. using su myusername. If you don't want to open a shell, you can always close the opened shell immediately by su myusername -c exit.

Alternatively, if you're a sudoer, use sudo -v to just update your timestamp. It will ask for your password, but not run anything else. This will not work if you recently entered your password for sudo though. You can invalidate your sudo timestamp using sudo -k though, so just run that before sudo -v (and maybe just afterwards, to be safe).

share|improve this answer
Thanks, any way I use use a pipe for this so I don't have to type the password manually? – 2rs2ts Jun 10 '13 at 23:16
@agarrett You can write a script that outputs your password, and specify the path to it in the SUDO_ASKPASS environment variable. Then run sudo -v -A. It's a stupid idea for obvious reasons though. – Daniel Beck Jun 10 '13 at 23:20
@agarrett Alternatively, echo pwd | sudo -S -v. Not great either. – Daniel Beck Jun 10 '13 at 23:26
If the latter outputs nothing, then it's the wrong password? – 2rs2ts Jun 10 '13 at 23:32
Hi @Daniel Beck, the solution you gave me has suddenly stopped working... I get a usage error now. – 2rs2ts Jun 17 '13 at 21:05

Using dscl, you can run this command to check a password on the localhost. If it returns nothing, the password was correct.

dscl /Local/Default -authonly USERNAME

If you want to check it on another password server, substitute accordingly

dscl /LDAPv3/ -authonly USERNAME
share|improve this answer

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.