sudo不能使用解决


sudo不能使用解决
 
今天装完系统发现我的sudo命令不能正常使用,大致情况如下:
.......
We trust you have received the usual lecture from the local System  
Administrator. It usually boils down to these three things:  
 
    #1) Respect the privacy of others.  
    #2) Think before you type.  
    #3) With great power comes great responsibility. 
...... 
 后来在网上查找了相关资料,具体解决方法如下:
1、用su - 登入root模式
2、改变文件sudoers的权限为可写:chmod 740 /etc/sudoers
3、用vi打开sudoers文件:vi /etc/sudoers
4、在root ALL=(ALL) ALL处回车,另起一行写上:username ALL=(ALL) ALL
5、保存退出
6、把sudoers的权限改为默认的440:chmod 440 /etc/sudoers
7、退出root到普通用户模式,使用sudo测试,通过!
注:如果想要在使用sudo时不输入密码,可以把4处改为:
username ALL=NOPASSWD:ALL
 
完整样例:
# /etc/sudoers 
# This file MUST be edited with the 'visudo' command as root. 
# See the man page for details on how to write a sudoers file. 
 
Defaults    env_reset 
 
# Host alias specification 
 
# User alias specification 
 
# Cmnd alias specification 
 
# User privilege specification 
root    ALL=(ALL) ALL 
#tiger   ALL=(ALL) ALL 
tiger   ALL=NOPASSWD:ALL 
 
# Uncomment to allow members of group sudo to not need a password 
# (Note that later entries override this, so you might need to move 
# it further down) 
# %sudo ALL=NOPASSWD: ALL 
 

相关内容

    暂无相关文章