Take the 2-minute tour ×
Unix & Linux Stack Exchange is a question and answer site for users of Linux, FreeBSD and other Un*x-like operating systems.. It's 100% free, no registration required.

I've been trying to run this Linux passwd-generator file on my Mac. I modified enough the script to make it to work well with directories under OSX:

# build-passwd.sh - creates a password file which contains all OS users (except root)
PASSWDIR=$(cd "$(dirname "$0")"; pwd)/etc
if [ ! -d "$PASSWDIR" ]; then
echo "$PASSWDIR created"
sudo awk -F":" '
{if ($1 != "root" && $2 != "!" && $2 != "*") print $1,$2}
' /etc/shadow > $PASSWFN **<===here's my problem**
if [ $? = 0 ]; then
echo "Password file saved to $PASSWFN"

But didn't succeed because there is no "/etc/shadow" on Mac.

So do you know if there is some alternative to this? (I also tried to copy/paste the file from my Linux installation using the same password)

share|improve this question

migrated from stackoverflow.com Aug 2 '12 at 1:59

This question came from our site for professional and enthusiast programmers.

3 Answers 3

Starting with Lion, there is a shadow file per user. All of those are stored in /var/db/dslocal/nodes/Default/users directory and are accessible by root only. For example:

$ ls -lah /var/db/dslocal/nodes/Default/users/
total 296
drwx------  77 root  wheel   2.6K Jul 27 20:30 .
drw-------  12 root  wheel   408B Jul 27 20:30 ..
-rw-------   1 root  wheel   4.0K Jul 27 20:30 Guest.plist
-rw-------   1 root  wheel   260B Jul 27 20:17 _amavisd.plist
-rw-------   1 root  wheel   254B Jul 27 20:17 _appleevents.plist
-rw-------   1 root  wheel   261B Jul 27 20:17 _appowner.plist
-rw-------   1 root  wheel   276B Jul 27 20:17 _appserver.plist

Also, those are binary property list files. The easiest way of viewing them is using plist command. For example:

$ plutil -p /var/db/dslocal/nodes/Default/users/root.plist 
  "smb_sid" => [
    0 => "XXXX-XXXX"
  "uid" => [
    0 => "0"
  "passwd" => [
    0 => "XXYYXX"

Hope it helps.

share|improve this answer

Mac OS X doesn't use the standard /etc/passwd and /etc/shadow. Instead, it uses a database. There use to be a GUI called NetInfo, but that has been replaced with the dscl command (Directory Services Command Line).

$ dscl
> read /Local/Default/Users/David Password
Password: ********

Unfortunately, that's about as far as I can get with the utility. It printed out asterisks instead of the password. Maybe there's a way to make it give up the hash, but I haven't found it.

Her's an article detailing using DSCL and cracking passwords on a Mac.

share|improve this answer

Have a look here..

Some info on missing /etc/shadow on OSX


share|improve this answer
downvoting because answerer did not paraphrase and instead simply linked to a web page, which is Stack Exchange bad practice. –  strugee Sep 5 '13 at 6:10
Upvoting because best practices ought to be enforced with a grain of salt, not undiscriminatorily. –  MariusMatutiae May 11 '14 at 14:24

Your Answer


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