sudo不能使用

今天装完系统发现我的sudo命令不能正常使用,大致情况如下:

 

 
 
  1. .......
  2. We trust you have received the usual lecture from the local System  
  3. Administrator. It usually boils down to these three things:  
  4.  
  5.     #1) Respect the privacy of others.  
  6.     #2) Think before you type.  
  7.     #3) With great power comes great responsibility. 
  8. ...... 

 后来在网上查找了相关资料,具体解决方法如下:

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

 


完整样例

 
 
  1. # /etc/sudoers 
  2. # This file MUST be edited with the 'visudo' command as root. 
  3. # See the man page for details on how to write a sudoers file. 
  4.  
  5. Defaults    env_reset 
  6.  
  7. # Host alias specification 
  8.  
  9. # User alias specification 
  10.  
  11. # Cmnd alias specification 
  12.  
  13. # User privilege specification 
  14. root    ALL=(ALL) ALL 
  15. #tiger   ALL=(ALL) ALL 
  16. tiger   ALL=NOPASSWD:ALL 
  17.  
  18. # Uncomment to allow members of group sudo to not need a password 
  19. # (Note that later entries override this, so you might need to move 
  20. # it further down) 
  21. # %sudo ALL=NOPASSWD: ALL 

 

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值