On OS X Mavericks, I am trying to create an account using single user mode, using the following script.
#! /bin/bash
# create user
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
However, when I run this script, I get 6 copies of the same error:
/System/Library/LaunchDaemons/com.apple.DirectoryServicesLocal.plist: No such file or directory
How do I fix this? Do I need to download a new /System/Library/LaunchDaemons/com.apple.DirectoryServicesLocal.plist ?
Thanks
Note: I have tried changed 401 to other values below 501, and I am getting the same result.
Best Answer
After starting in Single User Mode enter:
Launch opendirectoryd:
/System/Library/LaunchDaemons/com.apple.DirectoryServicesLocal.plist doesn't exist anymore!
Then execute:
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: