RUN0(1)

๐Ÿฆธ run0 โ€” like, the elevate-your-privileges era ๐Ÿ’…

okay bestie, welcome to the run0 manual page (section 1 of the manual, iykyk). this is the part where we tell you everything about it. buckle up. ๐ŸŽ€


โœจ NAME โœจ

run0 โ€” Elevate privileges ๐Ÿ‘‘


๐ŸŒธ SYNOPSIS ๐ŸŒธ

run0 [OPTIONS...] [COMMAND...]

๐Ÿ’– DESCRIPTION ๐Ÿ’–

so like, run0 lets you temporarily and interactively grab elevated privileges โ€” or just, like, different privileges. same energy as sudo(8) bestie, but the way it does it is a whole different vibe, and here's the key stuff:

  • No execution or security context credentials get inherited from the caller into the invoked commands. Nope, none. They're invoked from a fresh, isolated service that the service manager forks off. brand new, no hand-me-downs. โœจ
  • Authentication happens via polkit, which isolates the authentication prompt from the terminal (if that's even possible). so the auth convo is separated from your tty. slay.
  • An independent pseudo-tty gets allocated for the invoked command โ€” detaching its lifecycle and isolating it for security. main character gets its own little stage. ๐ŸŽ€
  • No SetUID/SetGID file access bit functionality is used for the implementation. not even a little bit.

and altogether? this is supposed to be a safer and more robust alternative to the whole sudo mechanism, especially in OS environments where SetUID/SetGID support isn't available (like, for example, by setting the NoNewPrivileges= variable in systemd-system.conf(5)). no cap.

Any session invoked via run0 will run through the "systemd-run0" PAM stack. that's just how it is. ๐Ÿ’…

also note: run0 is implemented as an alternative multi-call invocation of systemd-run(1). translation โ€” run0 is literally a symbolic link to the systemd-run executable file, and it behaves as run0 if it's invoked through the symbolic link. otherwise? it behaves as systemd-run. shapeshifter behavior, honestly iconic. ๐Ÿฆ‹

and one more thing, and this one matters: TTY isolation, as provided by the default value of the --pty option, is a core feature of run0. so redirecting terminals has to be done with care, avoiding giving such control to untrusted programs. don't be handing the aux cord to strangers, fr fr. ๐Ÿ˜ญ


๐ŸŒˆ OPTIONS ๐ŸŒˆ

the following options are understood, bestie. every single one:

  • --unit= โ€” Use this unit name instead of an automatically generated one.

Added in version 256.

  • --property= โ€” Sets a property of the service unit that is created. This option takes an assignment in the same format as systemctl(1)'s set-property command.

Added in version 256.

  • --description= โ€” Provide a description for the service unit that is invoked. If not specified, the command itself will be used as a description. See Description= in systemd.unit(5).

Added in version 256.

  • --slice= โ€” Make the new .service unit part of the specified slice, instead of user.slice. This option conflicts with --lightweight= and --area=, and implies "XDG_SESSION_CLASS=none", to keep the new process within the specified slice instead of a new session scope.

Added in version 256.

  • --slice-inherit โ€” Make the new .service unit part of the slice the run0 itself has been invoked in. This option may be combined with --slice=, in which case the slice specified via --slice= is placed within the slice the run0 command is invoked in. Also conflicts with --lightweight= and --area= and implies "XDG_SESSION_CLASS=none", similar to --slice=.

Example: consider run0 being invoked in the slice foo.slice, and the --slice= argument is bar. The unit will then be placed under foo-bar.slice.

Added in version 256.

  • --user=, -u, --group=, -g โ€” Switches to the specified user/group. If not specified defaults to "root", unless --area= or --empower are used (see below), in which case this defaults to the invoking user.

Added in version 256.

  • --nice= โ€” Runs the invoked session with the specified nice level.

Added in version 256.

  • --chdir=, -D โ€” Runs the invoked session with the specified working directory. If not specified defaults to the client's current working directory if switching to the root user, or the target user's home directory otherwise.

Added in version 256.

  • -k, --reset-timestamp โ€” Revokes temporary polkit authorization for this terminal, if present.

Added in version 262.

  • -K, --remove-timestamp โ€” Revokes all temporary polkit authorizations for this user session.

Added in version 262.

  • -v, --validate โ€” Request authorization from polkit. Can be used to create a temporary authorization without running a command.

Added in version 262.

  • --via-shell โ€” Invokes the target user's login shell and runs the specified command (if any) via it.

Added in version 258.

  • -i โ€” Shortcut for --via-shell --chdir='~'.

Added in version 258.

  • --setenv=NAME[=VALUE] โ€” Runs the invoked session with the specified environment variable set. This parameter may be used more than once to set multiple variables. When "=" and VALUE are omitted, the value of the variable with the same name in the invoking environment will be used.

Added in version 256.

  • --background=COLOR โ€” Change the terminal background color to the specified ANSI color as long as the session lasts. If not specified, the background will be tinted in a reddish tone when operating as root, and in a yellowish tone when operating under another UID, as reminder of the changed privileges. The color specified should be an ANSI X3.64 SGR background color, i.e. strings such as "40", "41", ..., "47", "48;2;...", "48;5;...". See ANSI Escape Code (Wikipedia) for details. Set to an empty string to disable.

Example: "--background=44" for a blue background. ๐Ÿ’™

Added in version 256.

  • --pty, --pty-late, --pipe โ€” Request allocation of a pseudo TTY for the run0 session (in case of --pty or --pty-late), or request passing the caller's STDIO file descriptors directly through (in case of --pipe). --pty-late is very similar to --pty but begins the TTY processing only once unit startup is complete, leaving input to any passwords/polkit agents until that time. If neither switch is specified, or if both --pipe and one of --pty/--pty-late are specified, the mode will be picked automatically: if standard input, standard output, and standard error output are all connected to a TTY then a pseudo TTY is allocated (in --pty-late mode unless --no-ask-password is specified in which case --pty is selected), otherwise the relevant file descriptors are passed through directly.

As mentioned above, TTY isolation as implemented by the default value of this option is crucial for security, so care must be taken when overriding it. ๐Ÿšจ

--pty and --pipe were added in v257.

--pty-late was added in v258.

  • --shell-prompt-prefix=STRING โ€” Set a shell prompt prefix string. This ultimately controls the $SHELL_PROMPT_PREFIX environment variable for the invoked program, which is typically imported into the shell prompt. By default โ€“ if emojis are supported โ€“, a superhero emoji is shown (๐Ÿฆธ). This default may also be changed (or turned off) by passing the $SYSTEMD_RUN_SHELL_PROMPT_PREFIX environment variable to run0, see below. Set to an empty string to disable shell prompt prefixing.

Added in version 257.

  • --lightweight=BOOLEAN โ€” Controls whether to activate the per-user service manager for the target user. By default (unset or set to auto), if the target user is "root" or a system user the per-user service manager is not activated as effect of the run0 invocation, otherwise it is.

This ultimately controls the $XDG_SESSION_CLASS environment variable pam_systemd(8) respects.

Added in version 258.

  • --area=AREA โ€” Controls the "area" of the target account to log into. Areas are secondary home directories within the primary home directory of the target user, i.e. logging into area "foobar" of an account translates to $HOME being set to ~/Areas/foobar on login.

If this option is used, the default user to transition to changes from root to the calling user's (but --user= takes precedence, see above). Or in other words, just specifying an area without a user is a mechanism to create a new session of the calling user, just with a different area. lowkey a whole personality change, but for your home dir. ๐Ÿฆ‹

This ultimately controls the $XDG_AREA environment variable pam_systemd(8) respects.

For details on the area concept see pam_systemd_home(8).

Added in version 258.

  • --empower โ€” If specified, run0 will elevate the privileges of the selected user (using --user=) or the current user if no user is explicitly selected. Currently this means we give the invoked process all available capabilities and add the "empower" group as a supplemental group (for which all polkit actions are allowed by default), but other privileges may be granted in the future as well when using this option.
Note that other (unprivileged) processes of the selected user will have privileges over the invoked process. Consider not using this option in an environment where there might be malicious processes running as the selected user. that's not a vibe, that's a warning. ๐Ÿ’€

Added in version 259.

  • --same-root-dir โ€” Execute the run0 session in the same root directory that the run0 command is executed in.

Added in version 259.

  • --machine= โ€” Execute operation in a local container. Specify a container name to connect to.

Added in version 256.

  • -n, --non-interactive โ€” Equivalent to --no-ask-password.

Added in version 262.

  • --no-ask-password โ€” Do not query the user for authentication for privileged operations.
  • -h, --help โ€” Print a short help text and exit.
  • -V, --version โ€” Print a short version string and exit.
  • --no-pager โ€” Do not pipe output into a pager. This currently only applies to --help. (The pager is not started during normal operation.)

Added in version 262.


okay so here's how the arguments work, bestie ๐Ÿ“

All command line arguments after the first non-option argument become part of the command line of the launched process. If no command line is specified an interactive shell is invoked. The shell to invoke may be controlled through --via-shell โ€” when specified the target user's shell is used โ€” or --setenv=SHELL=.... By default, the originating user's shell is executed if operating locally, or /bin/sh when operating with --machine=.

Note that unlike sudo, run0 always spawns shells with login shell semantics, regardless of -i. yes, always. periodt. ๐Ÿ’…

๐ŸŽ€ EXIT STATUS ๐ŸŽ€

On success, 0 is returned. If run0 failed to start the session or the specified command fails, a non-zero return value will be returned. simple as that. โœจ

๐ŸŒธ ENVIRONMENT VARIABLES ๐ŸŒธ

Okay bestie, listen up, because this part is lowkey important ๐Ÿ‘‘

Same energy as systemd-run: the session inherits the system environment from the service manager. That's the base layer. Then on top of that, run0 sets these extra ones for you:

  • $TERM โ€” copied straight from the $TERM of whoever called it (the caller, aka you). You can override it with --setenv=. Added in version 256.
  • $SUDO_USER โ€” set to the username of the originating user. The person who started all this. That's you ๐Ÿ’… Added in version 256.
  • $SUDO_UID โ€” set to the numeric UNIX user id of the originating user. Added in version 256.
  • $SUDO_GID โ€” set to the primary numeric UNIX group id of the originating session. Added in version 256.
  • $SHELL_PROMPT_PREFIX โ€” by default it's set to the superhero emoji (if supported ๐Ÿฆธ), but you can override it with the $SYSTEMD_RUN_SHELL_PROMPT_PREFIX environment variable (see right below, bestie) or with the --shell-prompt-prefix= switch (that one's up in OPTIONS, if you're nosy). Added in version 257.

And then there's this one, which is a variable you can pass in to run0 โ€” so it's giving โœจinputโœจ not output:

  • $SYSTEMD_RUN_SHELL_PROMPT_PREFIX โ€” if you set this, it overrides the default shell prompt prefix that run0 sets for the invoked shell (you know, the superhero emoji). Set it to an empty string to disable shell prompt prefixing entirely. No prefix, no problem, periodt. Added in version 257.
Not me double-checking that last bit: empty string = prefixing off. That's literally the whole rule. ๐Ÿ™ˆ

๐ŸŒˆ SEE ALSO ๐ŸŒˆ

The whole friend group, go say hi:


๐ŸŽ€ NOTES ๐ŸŽ€

  1. polkit โ€” https://www.freedesktop.org/wiki/Software/polkit
  2. ANSI Escape Code (Wikipedia) โ€” https://en.wikipedia.org/wiki/ANSI_escape_code#SGR_(Select_Graphic_Rendition)_parameters

and that's the whole page bestie, we ate and left no crumbs ๐Ÿ’–โœจ

This one's from systemd 262.1, and it's the RUN0(1) page โ€” section 1, manual page royalty, no cap ๐Ÿ‘‘ Go forth and run things as root, responsibly. mwah ๐Ÿซถ๐Ÿฆ‹๐ŸŒธ

๐Ÿ“ฆ where this page comes from
  • arch rolling: systemd 262.1-1 ยท LGPL-2.1-or-later AND CC0-1.0 AND GPL-2.0-or-later AND MIT-0
  • ๐Ÿ’– girlified by deepseek-ai/DeepSeek-V4.1-Flash on : a language model's rewrite of the original, under its terms