您的位置:首页 > 其它

设置 ubuntu sudo 时不用输密码

2014-07-02 01:15 225 查看
先提一下我的系统:LinuxMint 17 xfce 32-bits(基于 ubuntu 14.04 LTS)

ubuntu sudo 时输密码可烦人了,其实解决起来也不难,请看

我们先看看 sudo 的配置文件 $sudo cat /etc/sudoers

#

# This file MUST be edited with the 'visudo' command as root.

#

# Please consider adding local content in /etc/sudoers.d/ instead of

# directly modifying this file.

在注释中我们可以看到系统为了安全起见,不建议我们直接编辑这个配置文件(万一处理不好可能你就没法使用 sudo 了),而是编辑 /etc/sudoers.d/ 目录下的文件。好,我们就进入 /etc/sudoers.d/ 来看看

$ ls

mintupdate README

养成一个好习惯,先看 README ,

$sudo cat README

#

# As of Debian version 1.7.2p1-1, the default /etc/sudoers file created on

# installation of the package now includes the directive:

#

# #includedir /etc/sudoers.d

#

# This will cause sudo to read and parse any files in the /etc/sudoers.d

# directory that do not end in '~' or contain a '.' character.

#

# 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.

好了,此时你应该知道怎么做了吧,touch 一个文件 nopasswd4sudo,内容如下,

yourusername ALL=(ALL) NOPASSWD: ALL

完成之后,记得按要求 sudo chmod 0440 nopasswd4sudo 哦

更改完之后,sudo apt-get update 直接就更新了,说明sudo每次执行时都会先查看 /etc/sudoers.d/ 目录下的文件的
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: