Ever since I update to 16.04 I notice whenever I use any sudo command the terminal does not ask me the password before executing the command,The command is directly executed.I am the admin and I have no other user accounts.
I have seen sudo does not ask for password and my /etc/sudoers is exactly like given in answer but still when using sudo command, terminal does not prompt a password instead execute the command.
I would like to know in detail how can /etc/sudoers
can be modified for
-
Making any particular user account(including admin) to be prompted or not prompted for password when using sudo command.
-
How to exclude any particular command to be excluded from prompting password when using sudo for any user account(including admin).
Here is my sudoers file
# /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,timestamp_timeout=0
# Uncomment to allow members of group sudo to not need a password
# %sudo ALL=NOPASSWD: ALL
# Host alias specification
# User alias specification
# Cmnd alias specification
# User privilege specification root ALL=(ALL) ALL
# Members of the admin group may gain root privileges %admin ALL=(ALL) ALL
# See sudoers(5) for more information on "#include" directives:
#includedir /etc/sudoers.d
Output of sudo -l
Matching Defaults entries for bharat on ratcoder:
env_reset, timestamp_timeout=0
User bharat may run the following commands on ratcoder:
(ALL) NOPASSWD: ALL
Best Answer
You had a
NOPASSWD
rule applied to your user in some file in/etc/sudoers.d
. Usesudo grep NOPASSWD /etc/sudoers.d -R
to find out which.Your
/etc/sudoers
is not the default, however. The defaultsudoers
can be obtained by looking at thesudo
package:This is rather different from what you have. Restore
/etc/sudoers
to the default.For excluding specific commands from requiring a password, see How do I run specific sudo commands without a password?