配置普通用户有使用sudo命令的权限
2013-07-25 20:31
555 查看
在linux系统中,新建用户并没有执行sudo权限,如新建一个AAA的用户,输入sudo命令会有如下提示:
aaa is not in the sudoers file. This incident will be reported.
这句的意思是在sudoers文件中不存在aaa这个用户,这个时间会被报告给管理员。
既然知道问题处于sudoers这个文件,那我们就看看这个文件为何方神圣:
[root@dbs aaa]# vi /etc/sudoers
## Sudoers allows particular users to run various commands as
## the root user, without needing the root password.
##
## Examples are provided at the bottom of the file for collections
## of related commands, which can then be delegated out to particular
## users or groups.
##
## This file must be edited with the 'visudo' command.
## Host Aliases
## Groups of machines. You may prefer to use hostnames (perhaps using
## wildcards for entire domains) or IP addresses instead.
# Host_Alias FILESERVERS = fs1, fs2
# Host_Alias MAILSERVERS = smtp, smtp2
## User Aliases
## These aren't often necessary, as you can use regular groups
## (ie, from files, LDAP, NIS, etc) in this file - just use %groupname
## rather than USERALIAS
# User_Alias ADMINS = jsmith, mikem
输入i,对文件进行编辑,发现底部有只读提示:
-- INSERT -- W10: Warning: Changing a readonly file
应该是没有权限,退出编辑状态后查看权限:
[root@dbs aaa]# ll /etc/sudoers
-r--r-----. 1 root root 3825 Jul 22 01:05 /etc/sudoers
原来root也只有只读权限,难怪,首先修改权限以让root有完全控制权限:
[root@dbs aaa]#chmod 740 /etc/sudoers
再次编辑,这次没有出现只读提示了,找到如下字段:
## Allow root to run any commands anywhere
root ALL=(ALL) ALL
oracle ALL=(ALL) ALL
aaa ALL=(ALL) ALL
添加aaa用户,添加后如aaa ALL=(ALL) ALL
修改完后输入:wq保存,保存后记得把权限修改回去,否则会有错误提示
#chmod 440 /etc/sudoers
权限一定是440,否则就会有错误提示。
OK,在aaa用户下就可以正常使用sudo命令咯。
其实可以直接使用visudo命令编辑该文件,还不存在权限问题
aaa is not in the sudoers file. This incident will be reported.
这句的意思是在sudoers文件中不存在aaa这个用户,这个时间会被报告给管理员。
既然知道问题处于sudoers这个文件,那我们就看看这个文件为何方神圣:
[root@dbs aaa]# vi /etc/sudoers
## Sudoers allows particular users to run various commands as
## the root user, without needing the root password.
##
## Examples are provided at the bottom of the file for collections
## of related commands, which can then be delegated out to particular
## users or groups.
##
## This file must be edited with the 'visudo' command.
## Host Aliases
## Groups of machines. You may prefer to use hostnames (perhaps using
## wildcards for entire domains) or IP addresses instead.
# Host_Alias FILESERVERS = fs1, fs2
# Host_Alias MAILSERVERS = smtp, smtp2
## User Aliases
## These aren't often necessary, as you can use regular groups
## (ie, from files, LDAP, NIS, etc) in this file - just use %groupname
## rather than USERALIAS
# User_Alias ADMINS = jsmith, mikem
输入i,对文件进行编辑,发现底部有只读提示:
-- INSERT -- W10: Warning: Changing a readonly file
应该是没有权限,退出编辑状态后查看权限:
[root@dbs aaa]# ll /etc/sudoers
-r--r-----. 1 root root 3825 Jul 22 01:05 /etc/sudoers
原来root也只有只读权限,难怪,首先修改权限以让root有完全控制权限:
[root@dbs aaa]#chmod 740 /etc/sudoers
再次编辑,这次没有出现只读提示了,找到如下字段:
## Allow root to run any commands anywhere
root ALL=(ALL) ALL
oracle ALL=(ALL) ALL
aaa ALL=(ALL) ALL
添加aaa用户,添加后如aaa ALL=(ALL) ALL
修改完后输入:wq保存,保存后记得把权限修改回去,否则会有错误提示
#chmod 440 /etc/sudoers
权限一定是440,否则就会有错误提示。
OK,在aaa用户下就可以正常使用sudo命令咯。
其实可以直接使用visudo命令编辑该文件,还不存在权限问题
相关文章推荐
- 配置sudo 赋予普通用户对某些命令的执行权限
- CentOS6.6普通用户使用sudo命令借用root用户权限
- Sudo控制普通用户使用命令的权限
- centos配置普通用户可以使用sudo命令临时获取root权限
- CentOS6.6普通用户使用sudo命令借用root用户权限
- 给普通linux用户配置sudo的权限
- 如何使用sudo来允许普通用户使用超级用户权限
- Linux运维(ubuntu的普通用户如何使用sudo命令)
- linux 普通用户下sudo命令权限设置
- 如何使用sudo来允许普通用户使用超级用户权限
- Linux学习笔记之——普通用户使用sudo命令
- Linux普通用户使用sudo权限启停apache服务
- centos普通用户使用sudo命令
- 普通用户使用sudo命令借用root用户权限
- linux 下普通用户无法使用sudo命令的解决方法
- 使用sudo来赋予普通用户root的权限
- Linux普通用户使用sudo权限启停apache服务
- sudo配置文件写法:给普通用户增加权限
- redhat下给普通用户增加sudo命令,让他可以获得修改等权限
- rhel7 配置普通用户使用sudo