网站公众平台建设方案平面设计培训
给普通用户sudo权限
- 创建用户
- 安装sudo组件
- 设置sudo权限
- 切换到 root 用户、以root用户登录
- 修改 /etc/sudoers文件权限
- 修改 /etc/sudoers文件 (主要步骤)
- 保存退出
- 将 /etc/sudoers写权限改回来
- 结束
创建用户
useradd xwy //创建用户passwd xwy //为用户设置密码
安装sudo组件
如果没有sudo组件,则先安装
yum install sudo // Cenos系统apt-get install sudo //Ubuntu系统
设置sudo权限
切换到 root 用户、以root用户登录
修改 /etc/sudoers文件权限
使用 ls -l /etc/sudoers
查看权限:
-r--r----- 1 root root 3928 10月 10 16:35 /etc/sudoers
可以看到/etc/sudoers是只读的,可以修改文件权限,也可以修改以后wq!强制保存,这里使用前者
chmod u+w /etc/sudoers //增加写的权限,修改文件后,记得将权限改回来
修改 /etc/sudoers文件 (主要步骤)
## Allow root to run any commands anywhere
root ALL=(ALL) ALL## Allows members of the 'sys' group to run networking, software,
## service management apps and more.
# %sys ALL = NETWORKING, SOFTWARE, SERVICES, STORAGE, DELEGATING, PROCESSES, LOCATE, DRIVERS## Allows people in group wheel to run all commands
%wheel ALL=(ALL) ALL
xwy ALL=(ALL) ALL #这里就需要添加的地方
%whell 这一行是文件给出的格式,直接在这一行下面添加一行即可,这里假如我的用户为 xwy,添加:
xwy ALL=(ALL) ALL
保存退出
:wq
将 /etc/sudoers写权限改回来
chmod u-w /etc/sudoers
结束
可以使用sudo命令了