Debian Codegraph @

docs/man/sudo.8.md

raw symbols SCIP
1 ---
2 title: SUDO(8) sudo-rs 0.2.14 | sudo-rs
3 ---
4
5 # NAME
6
7 `sudo`, `sudoedit` - execute a command as another user
8
9 # SYNOPSIS
10
11 `sudo` `-h` | `-K` | `-k` | `-V`\
12 `sudo` \[`-u` *user*\] \[`-g` *group*\] \[`-D` *directory*\] \[`-BbknS`\] \[`-i` | `-s`\] \[`VAR=value`\] \[<*command*>\]\
13 `sudo` `-v` \[`-BknS`\] \[`-u` *user*\] \[`-g` *group*\]\
14 `sudo` `-l` \[`-BknS`\] \[`-U` *user*\] \[`-u` *user*\] \[`-g` *group*\] \[command \[arg ...\]\]\
15 `sudo` `-e` \[`-BknS`\] \[`-u` *user*\] \[`-g` *group*\] file ...\
16 `sudoedit` \[`-BknS`\] \[`-u` *user*\] \[`-g` *group*\] file ...
17
18
19 # DESCRIPTION
20
21 `sudo` allows a user that is permitted to do so to execute a *command* as
22 another user (for example *root*). Permissions are specified by a security
23 policy specified in `/etc/sudoers` (see sudoers(5)).
24
25 Sudo-rs is a safety oriented and memory safe re-implementation of the original
26 sudo implementation by Todd Miller.
27
28 When a command is run, a session record is stored for that specific session
29 allowing users to run additional commands without having to re-authenticate. The
30 timeout for session records can be specified in the policy.
31
32 Some care is taken to pass signals received by sudo-rs to the child process,
33 even if that process runs in its own pseudo terminal.
34
35 On systems where sudo is the primary method of gaining superuser privileges, it is
36 imperative to avoid syntax errors in the `/etc/sudoers` file. Changes to this file
37 should be made using the visudo(8) utility which will ensure that no syntax errors
38 are introduced.
39
40 # OPTIONS
41
42 `-A`, `--askpass`
43 : Normally, if sudo requires a password, it will read it from the user's terminal. If the -A (askpass) option is specified, a (possibly graphical)
44 helper program is executed to read the user's password and output the password to the standard output. If the SUDO_ASKPASS environment variable is
45 set, it specifies the path to the helper program. If no askpass program is available, sudo will exit with an error.
46
47 `-B`, `--bell`
48 : Ring the bell as part of the password prompt when a terminal is present.
49
50 `-b`, `--background`
51 : Run the given *command* in the background. It is not possible to use shell
52 job control to manipulate background processes started by sudo-rs. Most
53 interactive *command*s will fail to work properly in background mode.
54
55 `-D` *directory*, `--chdir`=*directory*
56 : Run the *command* in the specified *directory* instead of the current
57 working directory. The security policy may return an error if the user does
58 not have the permission to specify the working directory.
59
60 `-g` *group*, `--group`=*group*
61 : Use this *group* as the primary group instead of using the primary group
62 specified in the password database for the target user.
63
64 `-h`, `--help`
65 : Show a help message.
66
67 `-i`, `--login`
68 : Run the shell specified by the target user's password database entry as a
69 login shell. This means that login-specific resource files such as
70 *.profile*, *.bash_profile* or *.login* will be read by the shell. If a
71 *command* is specified, it is passed to the shell using the `-c` option.
72
73 `-K`, `--remove-timestamp`
74 : Removes every cached session record for the user, regardless of where the
75 command is executed. The next time sudo-rs is run, authentication will take
76 place if the policy requires it. No password is required to run this
77 command.
78
79 `-k`, `--reset-timestamp`
80 : When used without a command, invalidates the user's session record for
81 the current session. The next time sudo-rs is run, authentication will take
82 place if the policy requires it.
83
84 When used in conjunction with a *command* or an option that may require a
85 password, this option will cause sudo-rs to ignore the user's session
86 record. As a result, authentication will take place if the policy requires
87 it. When used in conjunction with a *command* no invalidation of existing
88 session records will take place.
89
90 `-n`, `--non-interactive`
91 : Avoid prompting the user for input of any kind. If any input is required for
92 the *command* to run, sudo-rs will display an error message and exit.
93
94 `-p`, `--prompt`=*prompt*
95 : Use a custom authentication prompt with optional escape sequences. The
96 following percent (‘%’) escape sequences are supported:
97
98 %H expanded to the local host name
99
100 %h expanded to the local host name without the domain name
101
102 %p expanded to the name of the user whose password is being requested
103 (this respects the rootpw, targetpw flags)
104
105 %U expanded to the login name of the user the command will be run as
106 (defaults to root unless the -u option is also specified)
107
108 %u expanded to the invoking user's login name
109
110 %% two consecutive ‘%’ characters are collapsed into a single ‘%’ character
111
112 The custom prompt will override the default prompt or the one specified by the SUDO_PROMPT environment variable.
113 No *prompt* will suppress the prompt provided by PAM, unless the requested *prompt* is empty (`""`)
114
115 `-S`, `--stdin`
116 : Read from standard input instead of using the terminal device.
117
118 `-s`, `--shell`
119 : Run the shell specified by the `SHELL` environment variable. If no shell
120 was specified, the shell from the user's password database entry will be
121 used instead. If a *command* is specified, it is passed to the shell using the `-c` option.
122
123 `--preserve-env=list`
124 : Indicates to the security policy that the user wishes to add the comma-separated list of environment variables to those preserved from the user's environment.
125 The security policy may return an error if the user does not have permission to preserve the environment. This option may be specified multiple times.
126
127 `-e`, `--edit`, `sudoedit`
128
129 : Edit one or more files instead of running a command. In lieu of a path name, the string "sudoedit" is used when consulting the security policy. If the user is authorized by the policy, the following steps are taken:
130
131 1. Temporary copies are made of the files to be edited with the owner set to the invoking user.
132
133 2. The editor specified by the policy is run to edit the temporary files. The sudoers policy uses the SUDO_EDITOR, VISUAL and EDITOR environment variables (in that order). If none of SUDO_EDITOR, VISUAL or EDITOR are set, the first program listed in the editor sudoers(5) option is used.
134
135 3. If they have been modified, the content of the temporary files is copied back to the originals and the temporary versions are removed.
136
137 To help prevent the editing of unauthorized files, the following restrictions are enforced (unless the user is root):
138
139 * Symbolic links may not be edited.
140
141 * If any component of the path leading to the file is writable by the invoking user, the file may not be edited.
142
143 * Users are never allowed to edit device special files.
144
145 If the specified file does not exist, it will be created. Unlike most commands run by sudo, the editor is run with the invoking user's environment unmodified. If the temporary file becomes empty after editing, the user will be prompted before it is installed.
146
147 `-u` *user*, `--user`=*user*
148 : Run the *command* as another user than the default (**root**).
149
150 `-V`, `--version`
151 : Display the current version of sudo-rs.
152
153 `-v`, `--validate`
154 : Update the session record for the current session, authenticating the user
155 if necessary.
156
157 `-l`, `--list`
158 : List user's privileges or check a specific command; use twice for longer format
159
160 `-U`, `--other-user`=*user*
161 : Used in list mode, display privileges for another user
162
163
164 `--`
165 : Indicates the end of the sudo-rs options and start of the *command*.
166
167 Environment variables to be set for the command may be passed on the command line in the form of VAR=value. Variables passed on the command line are subject to restrictions imposed by the security policy.
168 Variables passed on the command line are subject to the same restrictions as normal environment variables with one important exception: If the command to be run has the SETENV tag set or the command matched is ALL,
169 the user may set variables that would otherwise be forbidden. See [sudoers(5)](sudoers.5.md) for more information.
170
171 # SEE ALSO
172
173 [su(1)](su.1.md), [sudoers(5)](sudoers.5.md), [visudo(8)](visudo.8.md)