Su (Unix) Explained

su
Developer:AT&T Bell Laboratories
Operating System:Unix and Unix-like
Genre:Command

The Unix command , which stands for 'substitute user'[1] [2] (or historically 'superuser'[3] [4]), is used by a computer user to execute commands with the privileges of another user account. When executed it invokes a shell without changing the current working directory or the user environment.

When the command is used without specifying the new user id as a command line argument, it defaults to using the superuser account (user id 0) of the system.

History

The command, including the Unix permissions system and the setuid system call, was part of Version 1 Unix. Encrypted passwords appeared in Version 3.[5] The command is available as a separate package for Microsoft Windows as part of the UnxUtils collection of native Win32 ports of common GNU Unix-like utilities.[6]

The command was removed from GNU coreutils as of release 8.18 (2012-08-12)[7] and is currently included in the util-linux package.

Usage

When run from the command line, su asks for the target user's password, and if authenticated, grants the operator access to that account and the files and directories that account is permitted to access.

john@localhost:~$ su janePassword:jane@localhost:/home/john$ exitlogoutjohn@localhost:~$

When used with a hyphen it can be used to start a login shell. In this mode users can assume the user environment of the target user.

john@localhost:~$ su - janePassword:jane@localhost:~$

The command sudo is related, and executes a command as another user but observes a set of constraints about which users can execute which commands as which other users (generally in a configuration file named, best editable by the command). Unlike, authenticates users against their own password rather than that of the target user (to allow the delegation of specific commands to specific users on specific hosts without sharing passwords among them and while mitigating the risk of any unattended terminals).

Some Unix-like systems implement the user group wheel, and only allow members to become root with .[8] This may or may not mitigate these security concerns, since an intruder might first simply break into one of those accounts. GNU, however, does not support the group wheel for philosophical reasons. Richard Stallman argues that because the group would prevent users from utilizing root passwords leaked to them, the group would allow existing admins to ride roughshod over ordinary users.[9]

See also

Further reading

External links

Notes and References

  1. Web site: su(1) - Linux manual page . April 2, 2021 . .
  2. Web site: Unix Programmer's Manual, Seventh Edition, Volume 1 . 174 . January 1, 1979 . live . https://web.archive.org/web/20220120180645/https://s3.amazonaws.com/plan9-bell-labs/7thEdMan/v7vol1.pdf . Jan 20, 2022 . .
  3. Web site: Unix Programmer's Manual . November 3, 1971 . 17 . live . https://web.archive.org/web/20220317213155/https://www.bell-labs.com/usr/dmr/www/man13.pdf . March 17, 2022 . .
  4. Web site: Unix Programmer's Manual - Table of Contents . November 3, 1971 . live . https://web.archive.org/web/20220317213356/https://www.bell-labs.com/usr/dmr/www/pdfs/manindex.pdf . March 17, 2022 . .
  5. M. D. . McIlroy . Doug McIlroy . 1987 . A Research Unix reader: offticles annotated excerpts from the Programmer's Manual, 1971–1986 . CSTR . 139 . Bell Labs.
  6. Web site: Native Win32 ports of some GNU utilities. unxutils.sourceforge.net.
  7. Web site: NEWS. . 17 September 2022 .
  8. Book: Levi , Bozidar . UNIX Administration: A Comprehensive Sourcebook for Effective Systems and Network Management . limited . CRC Press . 2002 . 207 . 0-8493-1351-1.
  9. Web site: Why GNU su does not support the 'wheel' group . May 30, 2022 . live . https://web.archive.org/web/20210621182110/https://ftp.gnu.org/old-gnu/Manuals/coreutils-4.5.4/html_node/coreutils_149.html . June 21, 2021.