Ask Different is a question and answer site for power users of Apple hardware and software. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

Is there a way to detect single-user mode in OSX (Lion, specifically) from the command line?

I've tried who -r, which returns 3 in either standard or single-user mode.

I've also tried nvram boot-args, which does not work either.

Google isn't helping much with this...

share|improve this question
up vote 9 down vote accepted
$ sysctl -n kern.singleuser

It's 1 when booted in single-user mode, 0 when not.

share|improve this answer
Confirmed - thanks, Ingmar, just what I needed. – Scot Apr 12 '12 at 17:34

Hmm. We don't have runlevel in OS X*, which would be the easy way. How about identifying something in the output of launchctl list which is not present in single user mode but is present otherwise - might be a candidate.

*man who includes: -r Print the current runlevel. This is meaningless on Mac OS X.

share|improve this answer
Thanks, Adam - thought I'd try who anyway to confirm. As for launchctl list, it returns a Socket is not connected error when in Single User Mode...I wonder if that is enough of a hook? – Scot Apr 12 '12 at 0:49
Finder isn't always running even in 'normal mode'. It can be quit or replaced with another launcher. – user588 Apr 12 '12 at 0:51
If that's consistent Scot, it might be very convenient! – Adam Eberbach Apr 12 '12 at 0:53

In single user mode open directory is not available except by jumping through hoops. You can test the return value of dscl in that case.

share|improve this answer

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.