sudo 是 switch user do (切換用戶處理) 的簡寫。
sudo 允許係統管理員, 讓普通用戶執行一些或全部 root 命令。
sudo 不僅減少瞭 root 用戶的登錄 管理時間, 還提高瞭安全性。
sudo 不是對 Shell 的簡單代替, 可麵嚮所有命令。
另請參閱: su
sudo su
基本語法
sudo -h | -K | -k | -V sudo -v [-AknS] [-g group] [-h host] [-p prompt] [-u user] sudo -l [-AknS] [-g group] [-h host] [-p prompt] [-U user] [-u user] [command] sudo [-AbEHknPS] [-r role] [-t type] [-C num] [-g group] [-h host] [-p prompt] [-u user] [VAR=value] [-i|-s] [<command>] sudo -e [-AknS] [-r role] [-t type] [-C num] [-g group] [-h host] [-p prompt] [-u user] file ...
Options 選項
| 參數 | EN 解釋 | 中文翻譯 | 備注 |
|---|---|---|---|
| -A, --askpass | use a helper program for password prompting | 使用助手程序提示密碼 | |
| -b, --background | run command in the background | 在後颱運行命令 | |
| -C, --close-from=num | close all file descriptors >= num | 關閉 >= num 的所有文件描述符 | |
| -E, --preserve-env | preserve user environment when running command | 保留用戶環境, 當運行命令時 | |
| -e, --edit | edit files instead of running a command | 編輯文件而非運行命令 | |
| -g, --group=group | run command as the specified group name or ID | 由指定組名或 ID 運行命令 | |
| -H, --set-home | set HOME variable to target user's home dir | 把 HOME 變量設為目標用戶的主目錄 | |
| -h, --help | display help message and exit | 顯示幫助消息並退齣 | |
| -h, --host=host | run command on host (if supported by plugin) | 在主機上運行命令 (若插件支持) | |
| -i, --login |
run login shell as the target user; a command may also be specified |
由目標用戶運行登錄 Shell; 也可指定命令 |
|
| -K, --remove-timestamp | remove timestamp file completely | 完全移除時間戳文件 | |
| -k, --reset-timestamp | invalidate timestamp file | 使時間戳文件無效 | |
| -l, --list |
list user's privileges or check a specific command; use twice for longer format |
列錶用戶的特權或校驗特定命令; 使用兩次為更長格式 |
|
| -n, --non-interactive |
non-interactive mode, no prompts are used |
非交互模式, 使用時不提示 |
|
| -P, --preserve-groups | preserve group vector instead of setting to target's | 保留組嚮量,而非目標的設置 | |
| -p, --prompt=prompt | use the specified password prompt | 使用指定口令提示 | |
| -r, --role=role | create SELinux security context with specified role | 創建具有指定角色的 SELinux 安全上下文 | |
| -S, --stdin | read password from standard input | 從標準輸入讀取口令 | |
| -s, --shell |
run shell as the target user; a command may also be specified |
由目標用戶運行 Shell; 也可指定命令 |
|
| -t, --type=type | create SELinux security context with specified type | 創建具有指定類型的 SELinux 安全上下文 | |
| -U, --other-user=user |
in list mode, display privileges for user |
在列錶模式下, 顯示用戶特權 |
|
| -u, --user=user | run command (or edit file) as specified user name or ID | 由指定用戶名或 ID 運行命令 (或編輯文件) | |
| -V, --version | display version information and exit | 顯示版本信息並退齣 | |
| -v, --validate | update user's timestamp without running a command | 更新用戶的時間戳 (不運行命令) | |
| -- | stop processing command line arguments | 停止處理命令行自變量 |
| 功能 | 命令 | 文字解釋 | 示例 | 示例解釋 |
|---|---|---|---|---|
| 用戶 | sudo su | 變更用戶登入身份為 root | sudo su ls-ubuntu | 變更用戶登入身份為 ls-ubuntu |
| Shell | sudo -i -u USER | 以 USER 用戶登錄 Shell | sudo -i -u postgres | 以 postgres 用戶登錄 Shell |
| sudo --login --user USER | sudo --login --user postgres | |||
| 幫助 | sudo -h | 展示幫助信息 | ||
| sudo --help | ||||
| 版本 | sudo -V | 展示版本信息 | ||
| sudo --version |
版權聲明: 本文為獨傢原創稿件,版權歸 樂數軟件 ,未經許可不得轉載。