首页

sudo

sudo
功能说明:以其他身份来执行指令。
语  法:sudo [-bhHpV][-s <shell>][-u <用户>][指令] 或 sudo [-klv]
补充说明:sudo可让用户以其他的身份来执行指定的指令,预设的身份为root。在/etc/sudoers中设置了可执行sudo指令的用户。若其未经授权的用户企图使用sudo,则会发出警告的邮件给管理员。用户使用sudo时,必须先输入密码,之后有5分钟的有效期限,超过期限则必须重新输入密码。  
参  数:
 -b  在后台执行指令。 
 -h  显示帮助。 
 -H  将HOME环境变量设为新身份的HOME环境变量。 
 -k  结束密码的有效期限,也就是下次再执行sudo时便需要输入密码。 
 -l  列出目前用户可执行与无法执行的指令。 
 -p  改变询问密码的提示符号。 
 -s<shell>  执行指定的shell。 
 -u<用户>  以指定的用户作为新的身份。若不加上此参数,则预设以root作为新的身份。 
 -v  延长密码有效期限5分钟。 
 -V  显示版本信息。

sudo

sudo [options] [command]

If you are allowed, execute command as the superuser. Authorized users of sudo and the commands they are permitted to execute are listed in the sudo configuration file, /etc/sudoers. If an unauthorized user attempts to run a command, sudo will inform an administrator via email. By default, it will send the message to the root account. Users attempting to run commands are prompted for their password. Once authenticated, sudo sets a timestamp for the user. For five minutes from the timestamp, the user may execute further commands without being prompted for her password. This grace period may be overriden by settings in the /etc/sudoers file. Also see /etc/sudoers for configuration examples.

Options

-b

Execute command in the background.

-h

Print help message, then exit.

-k

Revoke user's sudo permissions. Similar to -K, but changes user's timestamp to the Epoch instead of revoking it.

-l

List all allowed and forbidden commands for the user on the current host, then exit.

-p promptstring

Use the specified promptstring to prompt for a password. The string may contain the following escape codes, which will be replaced with the current user's login name and local hostname.

%h

Local hostname without the domain name.

%H

Local hostname with the domain name.

%u

Current user's login name

%U

Login name of the user the command will run under. The default is root.

%%

A single percent (%) character.

-s

Run the shell specified in the SHELL environment variable, or the default shell specified in /etc/passwd. If a command is given, it should be a shell script and not a binary file.

-u user

Run command as the specified user instead of the root user. This may also be specified as a user ID number using #uid.

-v

Update timestamp for user. Prompt for password if necessary.

-H

Set the HOME environment variable to the home directory of the target user.

-K

Remove user's timestamp.

-L

List parameters that may be set as defaults for a user in the /etc/sudoers file.

-P

Preserve initial user's group membership.

-S

Read password from standard input instead of from the console.

-V

Print version number, then exit. When run by the root user, print sudo's defaults and the local network address as well.

--

Stop reading command-line arguments.