I want to run some things differently if I have booted into single-user/maintenance mode.

I want to know how I can test in my .bashrc file. In particular, I would like to start tmux only in that mode.


Where this info is found possibly varies by distro. Here's a couple of commands that may be helpful:

In Ubuntu Recovery mode (I assume this is single-user), who -r outputs nothing, and runlevel outputs an error runlevel:/var/run/utmp: No such file or directory

In Ubuntu normal boot mode (multi-user), you get the following output:

$ who -r
         run-level 2  2015-06-27 21:41
$ runlevel
N 2

Here runlevel outputs the previous run level ("N") and the current run level ("2").


Note that systemd based systems really don't have runlevels or anything like that, what services are active can be quite more fine grained. At least Fedora retains runlevel(8) and organizes running services into runlevels à la SysV, but that isn't mandatory.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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