logo

cross-unix-documentation

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

su.1x (2546B)


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