uid0(1) — Linux manual page


UID0(1)                           uid0                           UID0(1)

NAME         top

       uid0 - Elevate privileges

SYNOPSIS         top

       uid0 [OPTIONS...] [COMMAND...]

DESCRIPTION         top

       uid0 may be used to temporarily and interactively acquire
       elavated or different privileges. It serves a similar purpose as
       sudo(8), but operates differently in a couple of key areas:

       •   No execution or security context credentials are inherited
           from the caller into the invoked commands, as they are
           invoked from a fresh, isolated service forked off the service

       •   Authentication takes place via polkit[1], thus isolating the
           authentication prompt from the terminal (if possible).

       •   An independent pseudo-tty is allocated for the invoked
           command, detaching its lifecycle and isolating it for

       •   No SetUID/SetGID file access bit functionality is used for
           the implementation.

       Altogether this should provide a safer and more robust
       alternative to the sudo mechanism, in particular in OS
       environments where SetUID/SetGID support is not available (for
       example by setting the NoNewPrivileges= variable in

       Any session invoked via uid0 will run through the "systemd-uid0"
       PAM stack.

       Note that uid0 is implemented as an alternative multi-call
       invocation of systemd-run(1).

OPTIONS         top

       The following options are understood:

           Do not query the user for authentication for privileged

           Added in version 256.

           Use this unit name instead of an automatically generated one.

           Added in version 256.

           Sets a property on 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.

           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.

           Make the new .service unit part of the specified slice,
           instead of user.slice.

           Added in version 256.

           Make the new .service unit part of the slice the uid0 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 uid0 command is invoked in.

           Example: consider uid0 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 instead of root.

           Added in version 256.

           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.

           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.

           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)[2] for details.
           Set to an empty string to disable.

           Example: "--background=44" for a blue background.

           Added in version 256.

       -M, --machine=
           Execute operation on a local container. Specify a container
           name to connect to, optionally prefixed by a user name to
           connect as and a separating "@" character. If the special
           string ".host" is used in place of the container name, a
           connection to the local system is made (which is useful to
           connect to a specific user's user bus: "--user
           --machine=lennart@.host"). If the "@" syntax is not used, the
           connection is made as root user. If the "@" syntax is used
           either the left hand side or the right hand side may be
           omitted (but not both) in which case the local user name and
           ".host" are implied.

       -h, --help
           Print a short help text and exit.

           Print a short version string and exit.

       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 via --setenv=SHELL=...  and
       currently defaults to the originating user's shell (i.e. not the
       target user's!) if operating locally, or /bin/sh when operating
       with --machine=.

EXIT STATUS         top

       On success, 0 is returned. If uid0 failed to start the session or
       the specified command fails, a non-zero return value will be

SEE ALSO         top

       systemd(1), systemd-run(1), sudo(8), machinectl(1)

NOTES         top

        1. polkit

        2. ANSI Escape Code (Wikipedia)

COLOPHON         top

       This page is part of the systemd (systemd system and service
       manager) project.  Information about the project can be found at
       ⟨http://www.freedesktop.org/wiki/Software/systemd⟩.  If you have
       a bug report for this manual page, see
       This page was obtained from the project's upstream Git repository
       ⟨https://github.com/systemd/systemd.git⟩ on 2023-12-22.  (At that
       time, the date of the most recent commit that was found in the
       repository was 2023-12-22.)  If you discover any rendering
       problems in this HTML version of the page, or you believe there
       is a better or more up-to-date source for the page, or you have
       corrections or improvements to the information in this COLOPHON
       (which is not part of the original manual page), send a mail to

systemd 255                                                      UID0(1)

Pages that refer to this page: systemd-run(1)systemd.directives(7)systemd.index(7)