update init.d to clean new state location /var/lib/sudo, prepare to upload
[debian/sudo] / sudo.cat
1
2
3
4 SUDO(1m)               MAINTENANCE COMMANDS              SUDO(1m)
5
6
7 N\bNA\bAM\bME\bE
8        sudo, sudoedit - execute a command as another user
9
10 S\bSY\bYN\bNO\bOP\bPS\bSI\bIS\bS
11        s\bsu\bud\bdo\bo -\b-h\bh | -\b-K\bK | -\b-k\bk | -\b-L\bL | -\b-V\bV
12
13        s\bsu\bud\bdo\bo -\b-v\bv [-\b-A\bAk\bkn\bnS\bS] [-\b-a\ba _\ba_\bu_\bt_\bh_\b__\bt_\by_\bp_\be] [-\b-p\bp _\bp_\br_\bo_\bm_\bp_\bt]
14
15        s\bsu\bud\bdo\bo -\b-l\bl[\b[l\bl]\b] [-\b-A\bAk\bkn\bnS\bS] [-\b-a\ba _\ba_\bu_\bt_\bh_\b__\bt_\by_\bp_\be] [-\b-g\bg _\bg_\br_\bo_\bu_\bp_\bn_\ba_\bm_\be|_\b#_\bg_\bi_\bd] [-\b-p\bp _\bp_\br_\bo_\bm_\bp_\bt]
16        [-\b-U\bU _\bu_\bs_\be_\br_\bn_\ba_\bm_\be] [-\b-u\bu _\bu_\bs_\be_\br_\bn_\ba_\bm_\be|_\b#_\bu_\bi_\bd] [_\bc_\bo_\bm_\bm_\ba_\bn_\bd]
17
18        s\bsu\bud\bdo\bo [-\b-A\bAb\bbE\bEH\bHn\bnP\bPS\bS] [-\b-a\ba _\ba_\bu_\bt_\bh_\b__\bt_\by_\bp_\be] [-\b-C\bC _\bf_\bd] [-\b-c\bc _\bc_\bl_\ba_\bs_\bs|_\b-] [-\b-g\bg _\bg_\br_\bo_\bu_\bp_\bn_\ba_\bm_\be|_\b#_\bg_\bi_\bd]
19        [-\b-p\bp _\bp_\br_\bo_\bm_\bp_\bt] [-\b-u\bu _\bu_\bs_\be_\br_\bn_\ba_\bm_\be|_\b#_\bu_\bi_\bd] [V\bVA\bAR\bR=_\bv_\ba_\bl_\bu_\be] [-\b-i\bi | -\b-s\bs] [_\bc_\bo_\bm_\bm_\ba_\bn_\bd]
20
21        s\bsu\bud\bdo\boe\bed\bdi\bit\bt [-\b-A\bAn\bnS\bS] [-\b-a\ba _\ba_\bu_\bt_\bh_\b__\bt_\by_\bp_\be] [-\b-C\bC _\bf_\bd] [-\b-c\bc _\bc_\bl_\ba_\bs_\bs|_\b-] [-\b-g\bg _\bg_\br_\bo_\bu_\bp_\bn_\ba_\bm_\be|_\b#_\bg_\bi_\bd]
22        [-\b-p\bp _\bp_\br_\bo_\bm_\bp_\bt] [-\b-u\bu _\bu_\bs_\be_\br_\bn_\ba_\bm_\be|_\b#_\bu_\bi_\bd] file ...
23
24 D\bDE\bES\bSC\bCR\bRI\bIP\bPT\bTI\bIO\bON\bN
25        s\bsu\bud\bdo\bo allows a permitted user to execute a _\bc_\bo_\bm_\bm_\ba_\bn_\bd as the superuser or
26        another user, as specified in the _\bs_\bu_\bd_\bo_\be_\br_\bs file.  The real and effective
27        uid and gid are set to match those of the target user as specified in
28        the passwd file and the group vector is initialized based on the group
29        file (unless the -\b-P\bP option was specified).  If the invoking user is
30        root or if the target user is the same as the invoking user, no
31        password is required.  Otherwise, s\bsu\bud\bdo\bo requires that users authenticate
32        themselves with a password by default (NOTE: in the default
33        configuration this is the user's password, not the root password).
34        Once a user has been authenticated, a timestamp is updated and the user
35        may then use sudo without a password for a short period of time (5
36        minutes unless overridden in _\bs_\bu_\bd_\bo_\be_\br_\bs).
37
38        When invoked as s\bsu\bud\bdo\boe\bed\bdi\bit\bt, the -\b-e\be option (described below), is implied.
39
40        s\bsu\bud\bdo\bo determines who is an authorized user by consulting the file
41        _\b/_\be_\bt_\bc_\b/_\bs_\bu_\bd_\bo_\be_\br_\bs.  By running s\bsu\bud\bdo\bo with the -\b-v\bv option, a user can update
42        the time stamp without running a _\bc_\bo_\bm_\bm_\ba_\bn_\bd. The password prompt itself
43        will also time out if the user's password is not entered within 5
44        minutes (unless overridden via _\bs_\bu_\bd_\bo_\be_\br_\bs).
45
46        If a user who is not listed in the _\bs_\bu_\bd_\bo_\be_\br_\bs file tries to run a command
47        via s\bsu\bud\bdo\bo, mail is sent to the proper authorities, as defined at
48        configure time or in the _\bs_\bu_\bd_\bo_\be_\br_\bs file (defaults to root).  Note that
49        the mail will not be sent if an unauthorized user tries to run sudo
50        with the -\b-l\bl or -\b-v\bv option.  This allows users to determine for
51        themselves whether or not they are allowed to use s\bsu\bud\bdo\bo.
52
53        If s\bsu\bud\bdo\bo is run by root and the SUDO_USER environment variable is set,
54        s\bsu\bud\bdo\bo will use this value to determine who the actual user is.  This can
55        be used by a user to log commands through sudo even when a root shell
56        has been invoked.  It also allows the -\b-e\be option to remain useful even
57        when being run via a sudo-run script or program.  Note however, that
58        the sudoers lookup is still done for root, not the user specified by
59        SUDO_USER.
60
61
62
63
64 1.7.2p7                    June  1, 2010                        1
65
66
67
68
69
70 SUDO(1m)               MAINTENANCE COMMANDS              SUDO(1m)
71
72
73        s\bsu\bud\bdo\bo can log both successful and unsuccessful attempts (as well as
74        errors) to _\bs_\by_\bs_\bl_\bo_\bg(3), a log file, or both.  By default s\bsu\bud\bdo\bo will log
75        via _\bs_\by_\bs_\bl_\bo_\bg(3) but this is changeable at configure time or via the
76        _\bs_\bu_\bd_\bo_\be_\br_\bs file.
77
78 O\bOP\bPT\bTI\bIO\bON\bNS\bS
79        s\bsu\bud\bdo\bo accepts the following command line options:
80
81        -A          Normally, if s\bsu\bud\bdo\bo requires a password, it will read it from
82                    the current terminal.  If the -\b-A\bA (_\ba_\bs_\bk_\bp_\ba_\bs_\bs) option is
83                    specified, a (possibly graphical) helper program is
84                    executed to read the user's password and output the
85                    password to the standard output.  If the SUDO_ASKPASS
86                    environment variable is set, it specifies the path to the
87                    helper program.  Otherwise, the value specified by the
88                    _\ba_\bs_\bk_\bp_\ba_\bs_\bs option in _\bs_\bu_\bd_\bo_\be_\br_\bs(4) is used.
89
90        -a _\bt_\by_\bp_\be     The -\b-a\ba (_\ba_\bu_\bt_\bh_\be_\bn_\bt_\bi_\bc_\ba_\bt_\bi_\bo_\bn _\bt_\by_\bp_\be) option causes s\bsu\bud\bdo\bo to use the
91                    specified authentication type when validating the user, as
92                    allowed by _\b/_\be_\bt_\bc_\b/_\bl_\bo_\bg_\bi_\bn_\b._\bc_\bo_\bn_\bf.  The system administrator may
93                    specify a list of sudo-specific authentication methods by
94                    adding an "auth-sudo" entry in _\b/_\be_\bt_\bc_\b/_\bl_\bo_\bg_\bi_\bn_\b._\bc_\bo_\bn_\bf.  This
95                    option is only available on systems that support BSD
96                    authentication.
97
98        -b          The -\b-b\bb (_\bb_\ba_\bc_\bk_\bg_\br_\bo_\bu_\bn_\bd) option tells s\bsu\bud\bdo\bo to run the given
99                    command in the background.  Note that if you use the -\b-b\bb
100                    option you cannot use shell job control to manipulate the
101                    process.
102
103        -C _\bf_\bd       Normally, s\bsu\bud\bdo\bo will close all open file descriptors other
104                    than standard input, standard output and standard error.
105                    The -\b-C\bC (_\bc_\bl_\bo_\bs_\be _\bf_\br_\bo_\bm) option allows the user to specify a
106                    starting point above the standard error (file descriptor
107                    three).  Values less than three are not permitted.  This
108                    option is only available if the administrator has enabled
109                    the _\bc_\bl_\bo_\bs_\be_\bf_\br_\bo_\bm_\b__\bo_\bv_\be_\br_\br_\bi_\bd_\be option in _\bs_\bu_\bd_\bo_\be_\br_\bs(4).
110
111        -c _\bc_\bl_\ba_\bs_\bs    The -\b-c\bc (_\bc_\bl_\ba_\bs_\bs) option causes s\bsu\bud\bdo\bo to run the specified
112                    command with resources limited by the specified login
113                    class.  The _\bc_\bl_\ba_\bs_\bs argument can be either a class name as
114                    defined in _\b/_\be_\bt_\bc_\b/_\bl_\bo_\bg_\bi_\bn_\b._\bc_\bo_\bn_\bf, or a single '-' character.
115                    Specifying a _\bc_\bl_\ba_\bs_\bs of - indicates that the command should
116                    be run restricted by the default login capabilities for the
117                    user the command is run as.  If the _\bc_\bl_\ba_\bs_\bs argument
118                    specifies an existing user class, the command must be run
119                    as root, or the s\bsu\bud\bdo\bo command must be run from a shell that
120                    is already root.  This option is only available on systems
121                    with BSD login classes.
122
123        -E          The -\b-E\bE (_\bp_\br_\be_\bs_\be_\br_\bv_\be _\be_\bn_\bv_\bi_\br_\bo_\bn_\bm_\be_\bn_\bt) option will override the
124                    _\be_\bn_\bv_\b__\br_\be_\bs_\be_\bt option in _\bs_\bu_\bd_\bo_\be_\br_\bs(4)).  It is only available when
125                    either the matching command has the SETENV tag or the
126                    _\bs_\be_\bt_\be_\bn_\bv option is set in _\bs_\bu_\bd_\bo_\be_\br_\bs(4).
127
128
129
130 1.7.2p7                    June  1, 2010                        2
131
132
133
134
135
136 SUDO(1m)               MAINTENANCE COMMANDS              SUDO(1m)
137
138
139        -e          The -\b-e\be (_\be_\bd_\bi_\bt) option indicates that, instead of running a
140                    command, the user wishes to edit one or more files.  In
141                    lieu of a command, the string "sudoedit" is used when
142                    consulting the _\bs_\bu_\bd_\bo_\be_\br_\bs file.  If the user is authorized by
143                    _\bs_\bu_\bd_\bo_\be_\br_\bs the following steps are taken:
144
145                    1.  Temporary copies are made of the files to be edited
146                        with the owner set to the invoking user.
147
148                    2.  The editor specified by the SUDO_EDITOR, VISUAL or
149                        EDITOR environment variables is run to edit the
150                        temporary files.  If none of SUDO_EDITOR, VISUAL or
151                        EDITOR are set, the first program listed in the _\be_\bd_\bi_\bt_\bo_\br
152                        _\bs_\bu_\bd_\bo_\be_\br_\bs variable is used.
153
154                    3.  If they have been modified, the temporary files are
155                        copied back to their original location and the
156                        temporary versions are removed.
157
158                    If the specified file does not exist, it will be created.
159                    Note that unlike most commands run by s\bsu\bud\bdo\bo, the editor is
160                    run with the invoking user's environment unmodified.  If,
161                    for some reason, s\bsu\bud\bdo\bo is unable to update a file with its
162                    edited version, the user will receive a warning and the
163                    edited copy will remain in a temporary file.
164
165        -g _\bg_\br_\bo_\bu_\bp    Normally, s\bsu\bud\bdo\bo sets the primary group to the one specified
166                    by the passwd database for the user the command is being
167                    run as (by default, root).  The -\b-g\bg (_\bg_\br_\bo_\bu_\bp) option causes
168                    s\bsu\bud\bdo\bo to run the specified command with the primary group
169                    set to _\bg_\br_\bo_\bu_\bp.  To specify a _\bg_\bi_\bd instead of a _\bg_\br_\bo_\bu_\bp _\bn_\ba_\bm_\be,
170                    use _\b#_\bg_\bi_\bd.  When running commands as a _\bg_\bi_\bd, many shells
171                    require that the '#' be escaped with a backslash ('\').  If
172                    no -\b-u\bu option is specified, the command will be run as the
173                    invoking user (not root).  In either case, the primary
174                    group will be set to _\bg_\br_\bo_\bu_\bp.
175
176        -H          The -\b-H\bH (_\bH_\bO_\bM_\bE) option sets the HOME environment variable to
177                    the homedir of the target user (root by default) as
178                    specified in _\bp_\ba_\bs_\bs_\bw_\bd(4).  By default, s\bsu\bud\bdo\bo does not modify
179                    HOME (see _\bs_\be_\bt_\b__\bh_\bo_\bm_\be and _\ba_\bl_\bw_\ba_\by_\bs_\b__\bs_\be_\bt_\b__\bh_\bo_\bm_\be in _\bs_\bu_\bd_\bo_\be_\br_\bs(4)).
180
181        -h          The -\b-h\bh (_\bh_\be_\bl_\bp) option causes s\bsu\bud\bdo\bo to print a usage message
182                    and exit.
183
184        -i [command]
185                    The -\b-i\bi (_\bs_\bi_\bm_\bu_\bl_\ba_\bt_\be _\bi_\bn_\bi_\bt_\bi_\ba_\bl _\bl_\bo_\bg_\bi_\bn) option runs the shell
186                    specified in the _\bp_\ba_\bs_\bs_\bw_\bd(4) entry of the target user as a
187                    login shell.  This means that login-specific resource files
188                    such as .profile or .login will be read by the shell.  If a
189                    command is specified, it is passed to the shell for
190                    execution.  Otherwise, an interactive shell is executed.
191                    s\bsu\bud\bdo\bo attempts to change to that user's home directory
192                    before running the shell.  It also initializes the
193
194
195
196 1.7.2p7                    June  1, 2010                        3
197
198
199
200
201
202 SUDO(1m)               MAINTENANCE COMMANDS              SUDO(1m)
203
204
205                    environment, leaving _\bD_\bI_\bS_\bP_\bL_\bA_\bY and _\bT_\bE_\bR_\bM unchanged, setting
206                    _\bH_\bO_\bM_\bE, _\bS_\bH_\bE_\bL_\bL, _\bU_\bS_\bE_\bR, _\bL_\bO_\bG_\bN_\bA_\bM_\bE, and _\bP_\bA_\bT_\bH, as well as the
207                    contents of _\b/_\be_\bt_\bc_\b/_\be_\bn_\bv_\bi_\br_\bo_\bn_\bm_\be_\bn_\bt on Linux and AIX systems.  All
208                    other environment variables are removed.
209
210        -K          The -\b-K\bK (sure _\bk_\bi_\bl_\bl) option is like -\b-k\bk except that it removes
211                    the user's timestamp entirely and may not be used in
212                    conjunction with a command or other option.  This option
213                    does not require a password.
214
215        -k          When used by itself, the -\b-k\bk (_\bk_\bi_\bl_\bl) option to s\bsu\bud\bdo\bo
216                    invalidates the user's timestamp by setting the time on it
217                    to the Epoch.  The next time s\bsu\bud\bdo\bo is run a password will be
218                    required.  This option does not require a password and was
219                    added to allow a user to revoke s\bsu\bud\bdo\bo permissions from a
220                    .logout file.
221
222                    When used in conjunction with a command or an option that
223                    may require a password, the -\b-k\bk option will cause s\bsu\bud\bdo\bo to
224                    ignore the user's timestamp file.  As a result, s\bsu\bud\bdo\bo will
225                    prompt for a password (if one is required by _\bs_\bu_\bd_\bo_\be_\br_\bs) and
226                    will not update the user's timestamp file.
227
228        -L          The -\b-L\bL (_\bl_\bi_\bs_\bt defaults) option will list out the parameters
229                    that may be set in a _\bD_\be_\bf_\ba_\bu_\bl_\bt_\bs line along with a short
230                    description for each.  This option is useful in conjunction
231                    with _\bg_\br_\be_\bp(1).
232
233        -l[l] [_\bc_\bo_\bm_\bm_\ba_\bn_\bd]
234                    If no _\bc_\bo_\bm_\bm_\ba_\bn_\bd is specified, the -\b-l\bl (_\bl_\bi_\bs_\bt) option will list
235                    the allowed (and forbidden) commands for the invoking user
236                    (or the user specified by the -\b-U\bU option) on the current
237                    host.  If a _\bc_\bo_\bm_\bm_\ba_\bn_\bd is specified and is permitted by
238                    _\bs_\bu_\bd_\bo_\be_\br_\bs, the fully-qualified path to the command is
239                    displayed along with any command line arguments.  If
240                    _\bc_\bo_\bm_\bm_\ba_\bn_\bd is specified but not allowed, s\bsu\bud\bdo\bo will exit with a
241                    status value of 1.  If the -\b-l\bl option is specified with an l\bl
242                    argument (i.e. -\b-l\bll\bl), or if -\b-l\bl is specified multiple times,
243                    a longer list format is used.
244
245        -n          The -\b-n\bn (_\bn_\bo_\bn_\b-_\bi_\bn_\bt_\be_\br_\ba_\bc_\bt_\bi_\bv_\be) option prevents s\bsu\bud\bdo\bo from
246                    prompting the user for a password.  If a password is
247                    required for the command to run, s\bsu\bud\bdo\bo will display an error
248                    messages and exit.
249
250        -P          The -\b-P\bP (_\bp_\br_\be_\bs_\be_\br_\bv_\be _\bg_\br_\bo_\bu_\bp _\bv_\be_\bc_\bt_\bo_\br) option causes s\bsu\bud\bdo\bo to
251                    preserve the invoking user's group vector unaltered.  By
252                    default, s\bsu\bud\bdo\bo will initialize the group vector to the list
253                    of groups the target user is in.  The real and effective
254                    group IDs, however, are still set to match the target user.
255
256        -p _\bp_\br_\bo_\bm_\bp_\bt   The -\b-p\bp (_\bp_\br_\bo_\bm_\bp_\bt) option allows you to override the default
257                    password prompt and use a custom one.  The following
258                    percent (`%') escapes are supported:
259
260
261
262 1.7.2p7                    June  1, 2010                        4
263
264
265
266
267
268 SUDO(1m)               MAINTENANCE COMMANDS              SUDO(1m)
269
270
271                    %H  expanded to the local hostname including the domain
272                        name (on if the machine's hostname is fully qualified
273                        or the _\bf_\bq_\bd_\bn _\bs_\bu_\bd_\bo_\be_\br_\bs option is set)
274
275                    %h  expanded to the local hostname without the domain name
276
277                    %p  expanded to the user whose password is being asked for
278                        (respects the _\br_\bo_\bo_\bt_\bp_\bw, _\bt_\ba_\br_\bg_\be_\bt_\bp_\bw and _\br_\bu_\bn_\ba_\bs_\bp_\bw flags in
279                        _\bs_\bu_\bd_\bo_\be_\br_\bs)
280
281                    %U  expanded to the login name of the user the command will
282                        be run as (defaults to root)
283
284                    %u  expanded to the invoking user's login name
285
286                    %%  two consecutive % characters are collapsed into a
287                        single % character
288
289                    The prompt specified by the -\b-p\bp option will override the
290                    system password prompt on systems that support PAM unless
291                    the _\bp_\ba_\bs_\bs_\bp_\br_\bo_\bm_\bp_\bt_\b__\bo_\bv_\be_\br_\br_\bi_\bd_\be flag is disabled in _\bs_\bu_\bd_\bo_\be_\br_\bs.
292
293        -S          The -\b-S\bS (_\bs_\bt_\bd_\bi_\bn) option causes s\bsu\bud\bdo\bo to read the password from
294                    the standard input instead of the terminal device.  The
295                    password must be followed by a newline character.
296
297        -s [command]
298                    The -\b-s\bs (_\bs_\bh_\be_\bl_\bl) option runs the shell specified by the _\bS_\bH_\bE_\bL_\bL
299                    environment variable if it is set or the shell as specified
300                    in _\bp_\ba_\bs_\bs_\bw_\bd(4).  If a command is specified, it is passed to
301                    the shell for execution.  Otherwise, an interactive shell
302                    is executed.
303
304        -U _\bu_\bs_\be_\br     The -\b-U\bU (_\bo_\bt_\bh_\be_\br _\bu_\bs_\be_\br) option is used in conjunction with the
305                    -\b-l\bl option to specify the user whose privileges should be
306                    listed.  Only root or a user with s\bsu\bud\bdo\bo ALL on the current
307                    host may use this option.
308
309        -u _\bu_\bs_\be_\br     The -\b-u\bu (_\bu_\bs_\be_\br) option causes s\bsu\bud\bdo\bo to run the specified
310                    command as a user other than _\br_\bo_\bo_\bt.  To specify a _\bu_\bi_\bd
311                    instead of a _\bu_\bs_\be_\br _\bn_\ba_\bm_\be, use _\b#_\bu_\bi_\bd.  When running commands as
312                    a _\bu_\bi_\bd, many shells require that the '#' be escaped with a
313                    backslash ('\').  Note that if the _\bt_\ba_\br_\bg_\be_\bt_\bp_\bw Defaults option
314                    is set (see _\bs_\bu_\bd_\bo_\be_\br_\bs(4)) it is not possible to run commands
315                    with a uid not listed in the password database.
316
317        -V          The -\b-V\bV (_\bv_\be_\br_\bs_\bi_\bo_\bn) option causes s\bsu\bud\bdo\bo to print the version
318                    number and exit.  If the invoking user is already root the
319                    -\b-V\bV option will print out a list of the defaults s\bsu\bud\bdo\bo was
320                    compiled with as well as the machine's local network
321                    addresses.
322
323        -v          If given the -\b-v\bv (_\bv_\ba_\bl_\bi_\bd_\ba_\bt_\be) option, s\bsu\bud\bdo\bo will update the
324                    user's timestamp, prompting for the user's password if
325
326
327
328 1.7.2p7                    June  1, 2010                        5
329
330
331
332
333
334 SUDO(1m)               MAINTENANCE COMMANDS              SUDO(1m)
335
336
337                    necessary.  This extends the s\bsu\bud\bdo\bo timeout for another 5
338                    minutes (or whatever the timeout is set to in _\bs_\bu_\bd_\bo_\be_\br_\bs) but
339                    does not run a command.
340
341        --          The -\b--\b- option indicates that s\bsu\bud\bdo\bo should stop processing
342                    command line arguments.  It is most useful in conjunction
343                    with the -\b-s\bs option.
344
345        Environment variables to be set for the command may also be passed on
346        the command line in the form of V\bVA\bAR\bR=_\bv_\ba_\bl_\bu_\be, e.g.
347        L\bLD\bD_\b_L\bLI\bIB\bBR\bRA\bAR\bRY\bY_\b_P\bPA\bAT\bTH\bH=_\b/_\bu_\bs_\br_\b/_\bl_\bo_\bc_\ba_\bl_\b/_\bp_\bk_\bg_\b/_\bl_\bi_\bb.  Variables passed on the command
348        line are subject to the same restrictions as normal environment
349        variables with one important exception.  If the _\bs_\be_\bt_\be_\bn_\bv option is set in
350        _\bs_\bu_\bd_\bo_\be_\br_\bs, the command to be run has the SETENV tag set or the command
351        matched is ALL, the user may set variables that would overwise be
352        forbidden.  See _\bs_\bu_\bd_\bo_\be_\br_\bs(4) for more information.
353
354 R\bRE\bET\bTU\bUR\bRN\bN V\bVA\bAL\bLU\bUE\bES\bS
355        Upon successful execution of a program, the exit status from s\bsu\bud\bdo\bo will
356        simply be the exit status of the program that was executed.
357
358        Otherwise, s\bsu\bud\bdo\bo quits with an exit value of 1 if there is a
359        configuration/permission problem or if s\bsu\bud\bdo\bo cannot execute the given
360        command.  In the latter case the error string is printed to stderr.  If
361        s\bsu\bud\bdo\bo cannot _\bs_\bt_\ba_\bt(2) one or more entries in the user's PATH an error is
362        printed on stderr.  (If the directory does not exist or if it is not
363        really a directory, the entry is ignored and no error is printed.)
364        This should not happen under normal circumstances.  The most common
365        reason for _\bs_\bt_\ba_\bt(2) to return "permission denied" is if you are running
366        an automounter and one of the directories in your PATH is on a machine
367        that is currently unreachable.
368
369 S\bSE\bEC\bCU\bUR\bRI\bIT\bTY\bY N\bNO\bOT\bTE\bES\bS
370        s\bsu\bud\bdo\bo tries to be safe when executing external commands.
371
372        There are two distinct ways to deal with environment variables.  By
373        default, the _\be_\bn_\bv_\b__\br_\be_\bs_\be_\bt _\bs_\bu_\bd_\bo_\be_\br_\bs option is enabled.  This causes commands
374        to be executed with a minimal environment containing TERM, PATH, HOME,
375        SHELL, LOGNAME, USER and USERNAME in addition to variables from the
376        invoking process permitted by the _\be_\bn_\bv_\b__\bc_\bh_\be_\bc_\bk and _\be_\bn_\bv_\b__\bk_\be_\be_\bp _\bs_\bu_\bd_\bo_\be_\br_\bs
377        options.  There is effectively a whitelist for environment variables.
378
379        If, however, the _\be_\bn_\bv_\b__\br_\be_\bs_\be_\bt option is disabled in _\bs_\bu_\bd_\bo_\be_\br_\bs, any variables
380        not explicitly denied by the _\be_\bn_\bv_\b__\bc_\bh_\be_\bc_\bk and _\be_\bn_\bv_\b__\bd_\be_\bl_\be_\bt_\be options are
381        inherited from the invoking process.  In this case, _\be_\bn_\bv_\b__\bc_\bh_\be_\bc_\bk and
382        _\be_\bn_\bv_\b__\bd_\be_\bl_\be_\bt_\be behave like a blacklist.  Since it is not possible to
383        blacklist all potentially dangerous environment variables, use of the
384        default _\be_\bn_\bv_\b__\br_\be_\bs_\be_\bt behavior is encouraged.
385
386        In all cases, environment variables with a value beginning with () are
387        removed as they could be interpreted as b\bba\bas\bsh\bh functions.  The list of
388        environment variables that s\bsu\bud\bdo\bo allows or denies is contained in the
389        output of sudo -V when run as root.
390
391
392
393
394 1.7.2p7                    June  1, 2010                        6
395
396
397
398
399
400 SUDO(1m)               MAINTENANCE COMMANDS              SUDO(1m)
401
402
403        Note that the dynamic linker on most operating systems will remove
404        variables that can control dynamic linking from the environment of
405        setuid executables, including s\bsu\bud\bdo\bo.  Depending on the operating system
406        this may include _RLD*, DYLD_*, LD_*, LDR_*, LIBPATH, SHLIB_PATH, and
407        others.  These type of variables are removed from the environment
408        before s\bsu\bud\bdo\bo even begins execution and, as such, it is not possible for
409        s\bsu\bud\bdo\bo to preserve them.
410
411        To prevent command spoofing, s\bsu\bud\bdo\bo checks "." and "" (both denoting
412        current directory) last when searching for a command in the user's PATH
413        (if one or both are in the PATH).  Note, however, that the actual PATH
414        environment variable is _\bn_\bo_\bt modified and is passed unchanged to the
415        program that s\bsu\bud\bdo\bo executes.
416
417        s\bsu\bud\bdo\bo will check the ownership of its timestamp directory (_\b/_\bv_\ba_\br_\b/_\br_\bu_\bn_\b/_\bs_\bu_\bd_\bo
418        by default) and ignore the directory's contents if it is not owned by
419        root or if it is writable by a user other than root.  On systems that
420        allow non-root users to give away files via _\bc_\bh_\bo_\bw_\bn(2), if the timestamp
421        directory is located in a directory writable by anyone (e.g., _\b/_\bt_\bm_\bp), it
422        is possible for a user to create the timestamp directory before s\bsu\bud\bdo\bo is
423        run.  However, because s\bsu\bud\bdo\bo checks the ownership and mode of the
424        directory and its contents, the only damage that can be done is to
425        "hide" files by putting them in the timestamp dir.  This is unlikely to
426        happen since once the timestamp dir is owned by root and inaccessible
427        by any other user, the user placing files there would be unable to get
428        them back out.  To get around this issue you can use a directory that
429        is not world-writable for the timestamps (_\b/_\bv_\ba_\br_\b/_\ba_\bd_\bm_\b/_\bs_\bu_\bd_\bo for instance)
430        or create _\b/_\bv_\ba_\br_\b/_\br_\bu_\bn_\b/_\bs_\bu_\bd_\bo with the appropriate owner (root) and
431        permissions (0700) in the system startup files.
432
433        s\bsu\bud\bdo\bo will not honor timestamps set far in the future.  Timestamps with
434        a date greater than current_time + 2 * TIMEOUT will be ignored and sudo
435        will log and complain.  This is done to keep a user from creating
436        his/her own timestamp with a bogus date on systems that allow users to
437        give away files.
438
439        Please note that s\bsu\bud\bdo\bo will normally only log the command it explicitly
440        runs.  If a user runs a command such as sudo su or sudo sh, subsequent
441        commands run from that shell will _\bn_\bo_\bt be logged, nor will s\bsu\bud\bdo\bo's access
442        control affect them.  The same is true for commands that offer shell
443        escapes (including most editors).  Because of this, care must be taken
444        when giving users access to commands via s\bsu\bud\bdo\bo to verify that the
445        command does not inadvertently give the user an effective root shell.
446        For more information, please see the PREVENTING SHELL ESCAPES section
447        in _\bs_\bu_\bd_\bo_\be_\br_\bs(4).
448
449 E\bEN\bNV\bVI\bIR\bRO\bON\bNM\bME\bEN\bNT\bT
450        s\bsu\bud\bdo\bo utilizes the following environment variables:
451
452        EDITOR          Default editor to use in -\b-e\be (sudoedit) mode if neither
453                        SUDO_EDITOR nor VISUAL is set
454
455        HOME            In -\b-s\bs or -\b-H\bH mode (or if sudo was configured with the
456                        --enable-shell-sets-home option), set to homedir of the
457
458
459
460 1.7.2p7                    June  1, 2010                        7
461
462
463
464
465
466 SUDO(1m)               MAINTENANCE COMMANDS              SUDO(1m)
467
468
469                        target user
470
471        PATH            Set to a sane value if the _\bs_\be_\bc_\bu_\br_\be_\b__\bp_\ba_\bt_\bh sudoers option
472                        is set.
473
474        SHELL           Used to determine shell to run with -s option
475
476        SUDO_ASKPASS    Specifies the path to a helper program used to read the
477                        password if no terminal is available or if the -A
478                        option is specified.
479
480        SUDO_COMMAND    Set to the command run by sudo
481
482        SUDO_EDITOR     Default editor to use in -\b-e\be (sudoedit) mode
483
484        SUDO_GID        Set to the group ID of the user who invoked sudo
485
486        SUDO_PROMPT     Used as the default password prompt
487
488        SUDO_PS1        If set, PS1 will be set to its value for the program
489                        being run
490
491        SUDO_UID        Set to the user ID of the user who invoked sudo
492
493        SUDO_USER       Set to the login of the user who invoked sudo
494
495        USER            Set to the target user (root unless the -\b-u\bu option is
496                        specified)
497
498        VISUAL          Default editor to use in -\b-e\be (sudoedit) mode if
499                        SUDO_EDITOR is not set
500
501 F\bFI\bIL\bLE\bES\bS
502        _\b/_\be_\bt_\bc_\b/_\bs_\bu_\bd_\bo_\be_\br_\bs            List of who can run what
503
504        _\b/_\bv_\ba_\br_\b/_\br_\bu_\bn_\b/_\bs_\bu_\bd_\bo           Directory containing timestamps
505
506        _\b/_\be_\bt_\bc_\b/_\be_\bn_\bv_\bi_\br_\bo_\bn_\bm_\be_\bn_\bt        Initial environment for -\b-i\bi mode on Linux and
507                                AIX
508
509 E\bEX\bXA\bAM\bMP\bPL\bLE\bES\bS
510        Note: the following examples assume suitable _\bs_\bu_\bd_\bo_\be_\br_\bs(4) entries.
511
512        To get a file listing of an unreadable directory:
513
514         $ sudo ls /usr/local/protected
515
516        To list the home directory of user yaz on a machine where the file
517        system holding ~yaz is not exported as root:
518
519         $ sudo -u yaz ls ~yaz
520
521        To edit the _\bi_\bn_\bd_\be_\bx_\b._\bh_\bt_\bm_\bl file as user www:
522
523
524
525
526 1.7.2p7                    June  1, 2010                        8
527
528
529
530
531
532 SUDO(1m)               MAINTENANCE COMMANDS              SUDO(1m)
533
534
535         $ sudo -u www vi ~www/htdocs/index.html
536
537        To view system logs only accessible to root and users in the adm group:
538
539         $ sudo -g adm view /var/log/syslog
540
541        To run an editor as jim with a different primary group:
542
543         $ sudo -u jim -g audio vi ~jim/sound.txt
544
545        To shutdown a machine:
546
547         $ sudo shutdown -r +15 "quick reboot"
548
549        To make a usage listing of the directories in the /home partition.
550        Note that this runs the commands in a sub-shell to make the cd and file
551        redirection work.
552
553         $ sudo sh -c "cd /home ; du -s * | sort -rn > USAGE"
554
555 S\bSE\bEE\bE A\bAL\bLS\bSO\bO
556        _\bg_\br_\be_\bp(1), _\bs_\bu(1), _\bs_\bt_\ba_\bt(2), _\bl_\bo_\bg_\bi_\bn_\b__\bc_\ba_\bp(3), _\bp_\ba_\bs_\bs_\bw_\bd(4), _\bs_\bu_\bd_\bo_\be_\br_\bs(5),
557        _\bv_\bi_\bs_\bu_\bd_\bo(1m)
558
559 A\bAU\bUT\bTH\bHO\bOR\bRS\bS
560        Many people have worked on s\bsu\bud\bdo\bo over the years; this version consists
561        of code written primarily by:
562
563                Todd C. Miller
564
565        See the HISTORY file in the s\bsu\bud\bdo\bo distribution or visit
566        http://www.sudo.ws/sudo/history.html for a short history of s\bsu\bud\bdo\bo.
567
568 C\bCA\bAV\bVE\bEA\bAT\bTS\bS
569        There is no easy way to prevent a user from gaining a root shell if
570        that user is allowed to run arbitrary commands via s\bsu\bud\bdo\bo.  Also, many
571        programs (such as editors) allow the user to run commands via shell
572        escapes, thus avoiding s\bsu\bud\bdo\bo's checks.  However, on most systems it is
573        possible to prevent shell escapes with s\bsu\bud\bdo\bo's _\bn_\bo_\be_\bx_\be_\bc functionality.
574        See the _\bs_\bu_\bd_\bo_\be_\br_\bs(4) manual for details.
575
576        It is not meaningful to run the cd command directly via sudo, e.g.,
577
578         $ sudo cd /usr/local/protected
579
580        since when the command exits the parent process (your shell) will still
581        be the same.  Please see the EXAMPLES section for more information.
582
583        If users have sudo ALL there is nothing to prevent them from creating
584        their own program that gives them a root shell regardless of any '!'
585        elements in the user specification.
586
587        Running shell scripts via s\bsu\bud\bdo\bo can expose the same kernel bugs that
588        make setuid shell scripts unsafe on some operating systems (if your OS
589
590
591
592 1.7.2p7                    June  1, 2010                        9
593
594
595
596
597
598 SUDO(1m)               MAINTENANCE COMMANDS              SUDO(1m)
599
600
601        has a /dev/fd/ directory, setuid shell scripts are generally safe).
602
603 B\bBU\bUG\bGS\bS
604        If you feel you have found a bug in s\bsu\bud\bdo\bo, please submit a bug report at
605        http://www.sudo.ws/sudo/bugs/
606
607 S\bSU\bUP\bPP\bPO\bOR\bRT\bT
608        Limited free support is available via the sudo-users mailing list, see
609        http://www.sudo.ws/mailman/listinfo/sudo-users to subscribe or search
610        the archives.
611
612 D\bDI\bIS\bSC\bCL\bLA\bAI\bIM\bME\bER\bR
613        s\bsu\bud\bdo\bo is provided ``AS IS'' and any express or implied warranties,
614        including, but not limited to, the implied warranties of
615        merchantability and fitness for a particular purpose are disclaimed.
616        See the LICENSE file distributed with s\bsu\bud\bdo\bo or
617        http://www.sudo.ws/sudo/license.html for complete details.
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658 1.7.2p7                    June  1, 2010                       10
659
660