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:
#!/bin/sh
# build-passwd.sh - creates a password file which contains all OS users (except root)
PASSWDIR=$(cd "$(dirname "$0")"; pwd)/etc
PASSWFN=$PASSWDIR/passwd
if [ ! -d "$PASSWDIR" ]; then
mkdir $PASSWDIR
echo "$PASSWDIR created"
fi
sudo awk -F":" '
BEGIN {OFS=":"}
{if ($1 != "root" && $2 != "!" && $2 != "*") print $1,$2}
' /etc/shadow > $PASSWFN **<===here's my problem**
if [ $? = 0 ]; then
echo "Password file saved to $PASSWFN"
fi
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)
Best Answer
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:Also, those are binary property list files. The easiest way of viewing them is using
plist
command. For example: