Sudo

Revision as of 19:47, 25 May 2025 by imported>Maxeto0910 (no sentence)
(diff) ← Previous revision | Latest revision (diff) | Newer revision → (diff)

Template:Short description Template:Redirect Template:Lowercase title {{#invoke:Infobox|infobox}}Template:Template other{{#invoke:Check for unknown parameters | check | showblankpositional=1 | unknown = Template:Main other | preview = Page using Template:Infobox software with unknown parameter "_VALUE_"|ignoreblank=y | AsOf | author | background | bodystyle | caption | collapsetext | collapsible | developer | discontinued | engine | engines | genre | included with | language | language count | language footnote | latest preview date | latest preview version | latest release date | latest release version | latest_preview_date | latest_preview_version | latest_release_date | latest_release_version | licence | license | logo | logo alt | logo caption | logo upright | logo size | logo title | logo_alt | logo_caption | logo_upright | logo_size | logo_title | middleware | module | name | operating system | operating_system | other_names | platform | programming language | programming_language | released | replaced_by | replaces | repo | screenshot | screenshot alt | screenshot upright | screenshot size | screenshot title | screenshot_alt | screenshot_upright | screenshot_size | screenshot_title | service_name | size | standard | title | ver layout | website | qid }}Template:Main other

<syntaxhighlight lang="text" class="" style="" inline="1">sudo</syntaxhighlight> (Template:IPAc-en<ref name="todmil8"/>) is a shell command on Unix-like operating systems that enables a user to run a program with the security privileges of another user, by default the superuser.<ref name="nyt080526"/> It originally stood for "superuser do",<ref>{{#invoke:citation/CS1|citation |CitationClass=web }}</ref> as that was all it did, and this remains its most common usage;<ref>{{#invoke:citation/CS1|citation |CitationClass=web }}</ref> however, the official Sudo project page lists it as "su 'doTemplate:'".<ref>{{#invoke:citation/CS1|citation |CitationClass=web }}</ref> The current Linux manual pages define <syntaxhighlight lang="text" class="" style="" inline="1">su</syntaxhighlight> as "substitute user",<ref>{{#invoke:citation/CS1|citation |CitationClass=web }}</ref> making the correct meaning of <syntaxhighlight lang="text" class="" style="" inline="1">sudo</syntaxhighlight> "substitute user, do", because <syntaxhighlight lang="text" class="" style="" inline="1">sudo</syntaxhighlight> can run a command as other users as well.<ref>{{#invoke:citation/CS1|citation |CitationClass=web }}</ref><ref>Haeder, A.; Schneiter, S. A..; Pessanha, B. G.; Stanger, J. LPI Linux Certification in a Nutshell. O'Reilly Media, 2010. p. 409. Template:ISBN.</ref>

Unlike the similar command su, users must, by default, supply their own password for authentication, rather than the password of the target user. After authentication, and if the configuration file (typically /etc/sudoers) permits the user access, the system invokes the requested command. The configuration file offers detailed access permissions, including enabling commands only from the invoking terminal; requiring a password per user or group; requiring re-entry of a password every time or never requiring a password at all for a particular command line. It can also be configured to permit passing arguments or multiple commands.

HistoryEdit

Robert Coggeshall and Cliff Spencer wrote the original subsystem around 1980 at the Department of Computer Science at SUNY/Buffalo.<ref name="grati9"/> Robert Coggeshall brought sudo with him to the University of Colorado Boulder. Between 1986 and 1993, the code and features were substantially modified by the IT staff of the University of Colorado Boulder Computer Science Department and the College of Engineering and Applied Science, including Todd C. Miller.<ref name="grati9" /> The current version has been publicly maintained by OpenBSD developer Todd C. Miller since 1994,<ref name="grati9"/> and has been distributed under an ISC-style license since 1999.<ref name="grati9"/>

In November 2009 Thomas Claburn, in response to concerns that Microsoft had patented sudo,<ref name="maxi10"/> characterized such suspicions as overblown.<ref name="dark11"/> The claims were narrowly framed to a particular GUI, rather than to the sudo concept.<ref name="spi091112"/>

The logo is a reference to an xkcd strip, where an order for a sandwich is accepted when preceded with <syntaxhighlight lang="text" class="" style="" inline="1">sudo</syntaxhighlight>.<ref>{{#invoke:citation/CS1|citation |CitationClass=web }}</ref><ref>{{#invoke:citation/CS1|citation |CitationClass=web }}</ref>

DesignEdit

File:Sudo warning.svg
Warning when first using <syntaxhighlight lang="text" class="" style="" inline="1">sudo</syntaxhighlight>

Unlike for su, users supply their personal password to <syntaxhighlight lang="text" class="" style="" inline="1">sudo</syntaxhighlight> (if necessary)<ref name="iu.edu">{{#invoke:citation/CS1|citation |CitationClass=web }}</ref> rather than that of the superuser or other account. This allows authorized users to exercise altered privileges without compromising the secrecy of the other account's password.<ref>{{#invoke:citation/CS1|citation |CitationClass=web }}</ref> Users must be in a certain group to use the <syntaxhighlight lang="text" class="" style="" inline="1">sudo</syntaxhighlight> command, typically either the wheel or sudo group.<ref>{{#invoke:citation/CS1|citation |CitationClass=web }}</ref> After authentication, and if the configuration file permits the user access, the system invokes the requested command. <syntaxhighlight lang="text" class="" style="" inline="1">sudo</syntaxhighlight> retains the user's invocation rights through a grace period (typically 5 minutes) per pseudo terminal, allowing the user to execute several successive commands as the requested user without having to provide a password again.<ref>{{#invoke:citation/CS1|citation |CitationClass=web }}</ref>

As a security and auditing feature, <syntaxhighlight lang="text" class="" style="" inline="1">sudo</syntaxhighlight> may be configured to log each command run. When a user attempts to invoke <syntaxhighlight lang="text" class="" style="" inline="1">sudo</syntaxhighlight> without being listed in the configuration file, an exception indication is presented to the user indicating that the attempt has been recorded. If configured, the root user will be alerted via mail. By default, an entry is recorded in the system.<ref>Where are sudo Incidents Reported? Template:Webarchive Retrieved April 10, 2023</ref>

ConfigurationEdit

The /etc/sudoers file contains a list of users or user groups with permission to execute a subset of commands while having the privileges of the root user or another specified user. The file can be edited by using the command sudo vi sudo. Sudo contains several configuration options such as allowing commands to be run as <syntaxhighlight lang="text" class="" style="" inline="1">sudo</syntaxhighlight> without a password, changing which users can use <syntaxhighlight lang="text" class="" style="" inline="1">sudo</syntaxhighlight>, and changing the message displayed upon entering an incorrect password.<ref>{{#invoke:citation/CS1|citation |CitationClass=web }}</ref> Sudo features an easter egg that can be enabled from the configuration file that will display an insult every time an incorrect password is entered.<ref>{{#invoke:citation/CS1|citation |CitationClass=web }}</ref>

ImpactEdit

In some system distributions, <syntaxhighlight lang="text" class="" style="" inline="1">sudo</syntaxhighlight> has largely supplanted the default use of a distinct superuser login for administrative tasks, most notably in some Linux distributions as well as Apple's macOS.<ref name="ubunt5"/><ref name="macdv4"/> This allows for more secure logging of admin commands and prevents some exploits.

RBACEdit

{{#invoke:Labelled list hatnote|labelledList|Main article|Main articles|Main page|Main pages}}

In association with SELinux, <syntaxhighlight lang="text" class="" style="" inline="1">sudo</syntaxhighlight> can be used to transition between roles in role-based access control (RBAC).<ref>{{#invoke:citation/CS1|citation |CitationClass=web }}</ref>

Tools and similar programsEdit

visudo is a command-line utility that allows editing the sudo configuration file in a fail-safe manner. It prevents multiple simultaneous edits with locks and performs sanity and syntax checks.

Sudoedit is a program that symlinks to the sudo binary.<ref>{{#invoke:citation/CS1|citation |CitationClass=web }}</ref> When sudo is run via its sudoedit alias, sudo behaves as if the -e flag has been passed and allows users to edit files that require additional privileges to write to.<ref>{{#invoke:citation/CS1|citation |CitationClass=web }}</ref>

Microsoft released its own tool also called <syntaxhighlight lang="text" class="" style="" inline="1">sudo</syntaxhighlight> for Windows in February 2024. Its interface is similar to its Unix counterpart by giving the ability to run elevated commands from an unelevated console session, although its implementation is entirely different.<ref>{{#invoke:citation/CS1|citation |CitationClass=web }}</ref> The program runas provides comparable functionality in Windows, but it cannot pass current directories, environment variables or long command lines to the child. And while it supports running the child as another user, it does not support simple elevation. Hamilton C shell also includes true <syntaxhighlight lang="text" class="" style="" inline="1">su</syntaxhighlight> and <syntaxhighlight lang="text" class="" style="" inline="1">sudo</syntaxhighlight> for Windows that can pass all of that state information and start the child either elevated or as another user (or both).<ref>{{#invoke:citation/CS1|citation |CitationClass=web }}</ref><ref>{{#invoke:citation/CS1|citation |CitationClass=web }}</ref>

Graphical user interfaces exist for sudo – notably gksudo – but are deprecated in Debian and no longer included in Ubuntu.<ref>{{#invoke:citation/CS1|citation |CitationClass=web }}</ref><ref>{{#invoke:citation/CS1|citation |CitationClass=web }}</ref> Other user interfaces are not directly built on sudo, but provide similar temporary privilege elevation for administrative purposes, such as pkexec in Unix-like operating systems, User Account Control in Microsoft Windows and Mac OS X Authorization Services.<ref name="apple2"/>

doas, available since OpenBSD 5.8 (October 2015), has been written in order to replace <syntaxhighlight lang="text" class="" style="" inline="1">sudo</syntaxhighlight> in the OpenBSD base system, with the latter still being made available as a port.<ref>{{#invoke:citation/CS1|citation |CitationClass=web }}</ref>

gosu is a tool similar to sudo that is popular in containers where the terminal may not be fully functional or where there are undesirable effects from running sudo in a containerized environment.<ref>{{#invoke:citation/CS1|citation |CitationClass=web }}</ref>

See alsoEdit

Template:Portal

ReferencesEdit

Template:Reflist

External linksEdit

Template:Unix commands Template:OpenBSD