Ubuntu sudo不用输入密码的方法

在启动时进入安全模式,这时是用root登录的,执行: 

chmod 740 /etc/sudoers 


然后打开/etc/sudoers这个文件,把最后一行:

# User privilege specification
root    ALL=(ALL:ALL)  ALL
ucr     ALL=(ALL:ALL)  ALL

# Allow members of group sudo to execute any command
%sudo ALL=(ALL:ALL) ALL

改为 

# User privilege specification
root    ALL=(ALL:ALL)  ALL
ucr     ALL=(ALL:ALL) NOPASSWD:ALL

# Allow members of group sudo to execute any command
%sudo ALL=(ALL:ALL) NOPASSWD:ALL


保存退出。 

执行: 

chmod 0440 /etc/sudoers