3

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.

8
  • 1
    @MarkWright You posted a different bash script yesterday in a meanwhile deleted question. Please also include the "second half".
    – klanomath
    Mar 12 '16 at 17:38
  • 1
    I assume you've executed the commands: fsck -fy and mount -uw to check the disk and then mount it with write access? You may also need to preface each command with sudo.
    – IconDaemon
    Mar 12 '16 at 17:39
  • 1
    Does ls -l /System/Library/LaunchDaemons list some plists or does it give you a "No such file..." error?
    – nohillside
    Mar 12 '16 at 18:56
  • 2
    Also, see support.apple.com/en-us/HT4749
    – nohillside
    Mar 12 '16 at 18:59
  • 1
    Did the user get created actually? HT4749 implies that you can ignore the error message (assuming you've started OpenDirectory first)
    – nohillside
    Mar 12 '16 at 19:17
7
+50

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
3

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .