logo

cross-unix-documentation

documentation of similarities and (noteworthy) differencies between Unix systems git clone https://hacktivis.me/git/cross-unix-documentation.git

su.1x (2544B)


  1. .\" This file is part of Cross Unix Documentation
  2. .\" Copyright © 2019-2020 Haelwenn (lanodan) Monnier <contact@hacktivis.me>
  3. .\" SPDX-License-Identifier: CC-BY-4.0
  4. .Dd 2019-03-06
  5. .Dt SU 1x
  6. .Os
  7. .Sh PROLOG
  8. This manual page is part of
  9. .Lk https://hacktivis.me/git/cross-unix-documentation "Cross-Unix Documentation"
  10. 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.
  11. .Sh NAME
  12. .Nm su
  13. .Nd switch user / become superuser
  14. .Sh SYNOPSIS
  15. .Nm
  16. .Op Fl plm
  17. .Op Fl c Ar command
  18. .Op Fl s Ar shell
  19. .Op -
  20. .Op username Op shell arguments
  21. .Sh DESCRIPTION
  22. The
  23. .Nm
  24. utility is used to run a command or get a shell as another user, without having to log out.
  25. By default the environment is unmodified with the exception of
  26. .Ev LOGNAME ,
  27. .Ev HOME ,
  28. .Ev SHELL
  29. and
  30. .Ev USER .
  31. .Ev HOME and
  32. .Ev SHELL are set to the target user’s default values.
  33. .Ev LOGNAME
  34. and
  35. .Ev USER
  36. are set to the target user, unless the target user has a UID of 0 and
  37. .Fl l
  38. was not specified, in which case it is unmodified. The invoked shell is the target user’s. This is the traditional behaviour of su.
  39. If not using
  40. .Fl m
  41. and the target login has a UID of 0 then the
  42. .Ev PATH
  43. variable and umask are set to implementation defined behaviour.
  44. .Pp
  45. If
  46. .Op username
  47. was not set it defaults to UID 0 (also known as Super-User).
  48. .Bl -tag -width Ds
  49. .It - , Fl l
  50. Simulate a full login, this discards the origin user’s environment, expect for few implementation defined ones (like
  51. .Ev TERM
  52. ). Absent in BusyBox.
  53. .It Fl c Ar command
  54. Executes
  55. .Ar command
  56. as the target user. This flag is used for "login class" in
  57. .Nx ,
  58. .Fx and
  59. .Ox ,
  60. where you must pass the command by appending it to the end, along with the target user’s username.
  61. .It Fl p , Fl m
  62. Preserve the environment, few exceptions are present between implementations.
  63. GNU: preserve expect for
  64. .Ev PATH
  65. and
  66. .Ev IFS
  67. .It Fl s Ar shell
  68. Login to target user with
  69. .Ar shell
  70. instead of their default one. This is absent in
  71. .Nx
  72. and in
  73. .Fx
  74. is used to specify that the “MAC label” must be set and takes no argument.
  75. .It Op shell arguments
  76. Executes the remaining
  77. .Op shell arguments
  78. in the target user's shell non-interactively. This seems to be absent in Busybox.
  79. .Sh SOURCE
  80. GNU coreutils 8.30, Busybox 1.30.1,
  81. .Ox 6.4 ,
  82. .Nx 8.0 ,
  83. .Fx 12.0
  84. .Sh SEE ALSO
  85. .Xr sudo 1 ,
  86. .Xr doas 1 ,
  87. .Xr login 1 ,
  88. .Xr environ 7 .
  89. .Sh HISTORY
  90. A
  91. .Nm
  92. command appeared in
  93. .At v7 .
  94. .Sh AUTHORS
  95. .An Haelwenn (lanodan) Monnier Aq Mt contact+c-u-d@hacktivis.me