MacOS – Running shell scripts in single-user mode

bashmacosscriptsingle-user

I'm planning on running a couple of scripts in single-user mode to speed up (and simplify for less savvy users than myself) the configuring of a few aspects of some Macs that I set up for other people.

I've read the few threads I could find about this, and my question is simply is there anything I should be particularly aware of when it comes to running scripts from single-user mode?

I'm aware that I can't invoke any commands/apps that would require a GUI to load, and that the /sbin/fsck and /sbin/mount commands would still be required before a script can be run at all.

Two more specific questions: If I set the script as executable before depositing it on the disk image that will be booted in single-user mode, will it remain executable?

And lastly, when it comes to removing user accounts I've seen on some threads e.g this one the need to invoke this command:

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

However, as I simply want to rm various files – is there any need to do this, the process seems to work just fine without it?

Best Answer

Yes, files flagged as executable will still be executable under Single User Mode.

opendirectoryd is just for handling logins/authentication and using root doesn't require that, and you don't need to launch it if you just intend to manage files.

Related Question