受到这个问题的启发......
我是唯一一个在 12.04 上使用我的系统的人。
每次我发出sudo命令;系统要求输入用户密码(这有其自身的好处)。
然而我在想;无需激活root账户;如何执行不会要求用户密码进行身份验证的 sudo 命令。
注意:我想在不通过密码进行身份验证的情况下执行 sudo 命令;只有当它们通过终端执行时。
我不想从其他功能中删除这一额外的安全层,例如在使用“Ubuntu 软件中心”或通过将 something.sh 文件拖放到终端来执行 bash 脚本时。
这是一个与 sudoers 文件和 sudo 命令相关的相当复杂的问题。
注意:我在运行 Ubuntu Desktop 13.04 的专用机器上进行了这些更改,我仅将其用于学习目的。我知道启用 NOPASSWD sudo 会带来巨大的安全风险。
最初,我对 sudoers 文件 ( /etc/sudoers) 的唯一更改是一行,该用户规范应该使 nicholsonjf 能够使用 sudo 运行所有命令而无需输入密码(请参阅以 nicholsonjf 开头的行):
# 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.
#
# See the man page for details on how to write a sudoers file.
#
Defaults env_reset
Defaults mail_badpass
Defaults secure_path="/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin"
# Host …Run Code Online (Sandbox Code Playgroud) 每当我发出命令 sudo apt-get install **它不会要求输入密码,我的管理员用户也不会。
如何让它提示输入密码?
我的 sudoer :
ubuntu:~$ 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.
#
# See the man page for details on how to write a sudoers file.
#
Defaults env_reset
Defaults secure_path="/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin"
# Host alias specification
# User alias specification
# Cmnd alias specification
# User privilege specification
root …Run Code Online (Sandbox Code Playgroud)