sudo 命令没有密码提示

dat*_*ta9 15 sudo

每当我发出命令 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    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
ALL ALL=(ALL) NOPASSWD:ALL
Run Code Online (Sandbox Code Playgroud)

Eli*_*gan 19

/etc/sudoers使用编辑sudo visudo,并删除最后一行:

ALL ALL=(ALL) NOPASSWD:ALL
Run Code Online (Sandbox Code Playgroud)

(顺便说一句,请注意,这条线在文件的结尾是不是做的首选方式sudo 提示输入密码,对于那些谁想要做到这一点。)

  • 好的,那么让 sudo 不提示输入密码的首选方法是什么? (2认同)

小智 5

使用此命令查找问题的根源:

sudo grep -HRn NOPASSWD /etc/sudoers.d/
Run Code Online (Sandbox Code Playgroud)

就我而言:

/etc/sudoers.d/50_stack_sh:1:username ALL=(root) NOPASSWD:ALL
Run Code Online (Sandbox Code Playgroud)

用 # 注释该行并关闭您的终端。