受此问题启发....
我是将我的系统与12.04一起使用的唯一人。
每次我发出sudo
命令;系统要求输入用户密码(以其自身的方式,这是很好的)。
但是我在想;无需激活根帐户;如何执行不要求用户密码进行身份验证的sudo命令。
注意:我想执行sudo命令而不通过密码进行身份验证;仅当它们通过终端执行时。
我不想在使用“ Ubuntu软件中心”或通过将something.sh文件拖放到终端来执行bash脚本的同时从其他功能中删除此额外的安全保护层。
您可以配置sudo
为从不要求输入密码。
打开一个终端窗口,然后键入:
sudo visudo
在文件底部,添加以下行:
$USER ALL=(ALL) NOPASSWD: ALL
$USER
您的系统上的用户名在哪里。保存并关闭sudoers文件(如果您尚未更改默认的终端编辑器(您将知道是否已安装),请按Ctl + x退出nano
,它会提示您进行保存)。
从Ubuntu 19.04开始,该文件现在应类似于
#
# 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:/snap/bin"
# Host alias specification
# User alias specification
# Cmnd alias specification
# User privilege specification
root ALL=(ALL:ALL) ALL
# Members of the admin group may gain root privileges
%admin ALL=(ALL) ALL
# Allow members of group sudo to execute any command
%sudo ALL=(ALL:ALL) ALL
# See sudoers(5) for more information on "#include" directives:
#includedir /etc/sudoers.d
YOUR_USERNAME_HERE ALL=(ALL) NOPASSWD: ALL
之后,您可以sudo <whatever you want>
在“终端”窗口中键入密码,而无需提示输入密码。
这仅适用sudo
于在终端中使用命令。如果您(例如)尝试从软件中心安装软件包,系统仍会提示您输入密码
本文收集自互联网,转载请注明来源。
如有侵权,请联系 [email protected] 删除。
我来说两句