Error while trying to create an account in single user mode on OS X Mavericks
After starting in Single User Mode enter:

/sbin/fsck -fy
/sbin/mount -uw /


Launch opendirectoryd:

launchctl load /System/Library/LaunchDaemons/com.apple.opendirectoryd.plist


/System/Library/LaunchDaemons/com.apple.DirectoryServicesLocal.plist doesn't exist anymore!

Then execute:

dscl . -create /Users/hiddenuser
dscl . -create /Users/hiddenuser UserShell /bin/bash
dscl . -create /Users/hiddenuser RealName "Hidden User"
dscl . -create /Users/hiddenuser UniqueID "401"
dscl . -create /Users/hiddenuser PrimaryGroupID 20
dscl . -create /Users/hiddenuser NFSHomeDirectory /var/hiddenuser
dscl . -passwd /Users/hiddenuser password


The commands yield errors but the user is properly created. Executing /bin/bash /path/to/script.sh directly after loading opendirectoryd didn't work for me for no apparent reason. On a second attempt using a UID >500 it worked though!

In Yosemite and more recent OS X versions creating a hidden user like this is not recommend. Instead use a free UniqueID >500 and use an additional command:

dscl . -create /Users/hiddenuser IsHidden 1