2019-10-11 10:04:28 +08:00
|
|
|
# Sudo 授权普通账户
|
|
|
|
|
2019-10-11 10:16:18 +08:00
|
|
|
首先以 root 身份登陆系统。
|
2019-10-11 10:04:28 +08:00
|
|
|
|
2019-10-11 10:16:18 +08:00
|
|
|
## 检查 /bin/sudo 是否有 s 位权限
|
2019-10-11 10:04:28 +08:00
|
|
|
|
|
|
|
```sh
|
|
|
|
ll /bin/sudo
|
|
|
|
-rwsr-xr-x 1 root root
|
|
|
|
```
|
|
|
|
|
|
|
|
如果不存在则添加上:
|
|
|
|
|
|
|
|
```sh
|
|
|
|
chmod +s /bin/sudo
|
|
|
|
```
|
|
|
|
|
|
|
|
## 编辑 /etc/sudoers 文件
|
|
|
|
|
|
|
|
先增加写权限:
|
|
|
|
|
|
|
|
```sh
|
|
|
|
chmod +w /etc/sudoers
|
|
|
|
```
|
|
|
|
|
|
|
|
之后编辑该文件,在:
|
|
|
|
|
|
|
|
```sh
|
|
|
|
root ALL=(ALL) ALL
|
|
|
|
```
|
|
|
|
|
|
|
|
这行下面增加一行,格式为:
|
|
|
|
|
|
|
|
```sh
|
|
|
|
<system user name> ALL=(ALL) ALL
|
|
|
|
```
|
|
|
|
|
|
|
|
保存退出后关闭写权限:
|
|
|
|
|
|
|
|
```sh
|
|
|
|
chmod -w /etc/sudoers
|
|
|
|
```
|