让 sudo 命令不用输入密码

首先执行以下命令(该命令用来修改 /etc/sudoers 文件):

$ sudo visudo
然后把 # %sudo 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
然后再执行以下命令:
$ sudo adduser `whoami` sudo

就可以了。

第一步的作用是使隶属于 sudo 组的用户在执行 sudo 命令时不需要输入密码。

第二步的作用是把你自己加入 sudo 组。

请参阅 Ubuntu 中文论坛的贴子“让 sudo 不在输入密码”的第 40 楼。
posted @ 2009-05-24 22:00  MoDa  阅读(663)  评论(0编辑  收藏  举报