您的位置:首页 > 其它

为某个用户增加 sudo 权限

2013-03-05 17:04 134 查看

修改/etc/sudoers文件

方法一(不推荐)

#visudo -f /etc/sudoers
在root ALL=(ALL) ALL 之后增加
tom ALL=(ALL) ALL
Defaults:tom timestamp_timeout=2,runaspw
# 增加普通账户tom的sudo权限

# timestamp_timeout=-1 只需验证一次密码,以后系统自动记忆,这里设的是 2 分钟
# runaspw  需要root密码,如果不加默认是要输入普通账户的密码

方法二(推荐)

注:如果软件升级, /etc/sudoers 可能会被覆盖掉,所以好的习惯是在 /etc/sudoers.d 中添加

在 /etc/sudoers.d 目录中增加一个文件,添加相同的内容

tom ALL=(ALL) ALL
Defaults:tom timestamp_timeout=2,runaspw


注意(如果发现没有成功,看是否满足下面2个条件):

1. The file in /etc/sudoers do not end in '~' or contain a '.' character

2. Note that there must be at least one file in the sudoers.d directory (this one will do), and all files in this directory
should be mode 0440.

(/etc/sudoers.d/README in Ubuntu)

修改 PATH

修改普通用户的.bash_profile文件(vi /home/tom/.bash_profile),在PATH变量中增加
/sbin:/usr/sbin:/usr/local/sbin:/usr/kerberos/sbin
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: