su.1x (2546B)
- .\" This file is part of Cross Unix Documentation
- .\" Copyright © 2019-2020 Haelwenn (lanodan) Monnier <contact@hacktivis.me>
- .\" SPDX-License-Identifier: CC-BY-4.0
- .Dd 2019-03-06
- .Dt SU 1x
- .Os
- .Sh PROLOG
- This manual page is part of
- .Lk https://hacktivis.me/git/cross-unix-documentation "Cross-Unix Documentation"
- which is an attempt to provide documentation of similarities and (noteworthy) differencies between Unix-like systems.
- To be used as an addition to the POSIX standard.
- .Sh NAME
- .Nm su
- .Nd switch user / become superuser
- .Sh SYNOPSIS
- .Nm
- .Op Fl plm
- .Op Fl c Ar command
- .Op Fl s Ar shell
- .Op -
- .Op username Op shell arguments
- .Sh DESCRIPTION
- The
- .Nm
- utility is used to run a command or get a shell as another user, without having to log out.
- By default the environment is unmodified with the exception of
- .Ev LOGNAME ,
- .Ev HOME ,
- .Ev SHELL
- and
- .Ev USER .
- .Ev HOME and
- .Ev SHELL
- are set to the target user’s default values.
- .Ev LOGNAME
- and
- .Ev USER
- are set to the target user, unless the target user has a UID of 0 and
- .Fl l
- was not specified, in which case it is unmodified.
- The invoked shell is the target user’s.
- This is the traditional behaviour of su.
- If not using
- .Fl m
- and the target login has a UID of 0 then the
- .Ev PATH
- variable and umask are set to implementation defined behaviour.
- .Pp
- If
- .Op username
- was not set it defaults to UID 0 (also known as Super-User).
- .Bl -tag -width Ds
- .It - , Fl l
- Simulate a full login, this discards the origin user’s environment, expect for few implementation defined ones (like
- .Ev TERM
- ). Absent in BusyBox.
- .It Fl c Ar command
- Executes
- .Ar command
- as the target user.
- This flag is used for "login class" in
- .Nx ,
- .Fx and
- .Ox ,
- where you must pass the command by appending it to the end, along with the target user’s username.
- .It Fl p , Fl m
- Preserve the environment, few exceptions are present between implementations.
- GNU: preserve expect for
- .Ev PATH
- and
- .Ev IFS
- .It Fl s Ar shell
- Login to target user with
- .Ar shell
- instead of their default one.
- This is absent in
- .Nx
- and in
- .Fx
- is used to specify that the “MAC label” must be set and takes no argument.
- .It Op shell arguments
- Executes the remaining
- .Op shell arguments
- in the target user's shell non-interactively.
- This seems to be absent in Busybox.
- .El
- .Sh SOURCE
- GNU coreutils 8.30, Busybox 1.30.1,
- .Ox 6.4 ,
- .Nx 8.0 ,
- .Fx 12.0
- .Sh SEE ALSO
- .Xr doas 1 ,
- .Xr login 1 ,
- .Xr sudo 1 ,
- .Xr environ 7
- .Sh HISTORY
- A
- .Nm
- command appeared in
- .At v7 .
- .Sh AUTHORS
- .An Haelwenn (lanodan) Monnier Aq Mt contact+c-u-d@hacktivis.me