I have added my user in sudoers file, after a restart ubuntu still requires password to execute command.
Below is my sudoers file.
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
aman ALL=(ALL:ALL) ALL
Here "aman" is current loggedin user name.
Actually in my ubuntu 16.04 I am facing wifi issue which I am able to resolve using below command but I want to execute this command on startup without prompting for password.
systemctl restart network-manager.serviceroot
I have also tried below command but no sucess, every time I am going to execute command ubuntu prompt me to enter password.
usermod -aG sudo username
UPDATE :- Now below is my sudoers file screen shot
Note:- When I execute whoami command terminal shows "aman"
You should use NOPASSWD option
However, I would not recommend it that way, because user
aman
can execute anything without password. I would only allow the systemctl command to be executed without password like this:It is safer that way.
This is the normal behaviour, being in the sudoers list only means that you can use the
sudo
command, but you'll be asked for your password.If you want to use sudo without password, you need to add
NOPASSWD:ALL
afteraman ALL=(ALL:ALL)
in/etc/sudoers
(the line would look like
aman ALL=(ALL:ALL) NOPASSWD:ALL
)see here
I dont know if its too late to answer. But I ran into same problem recently and nothing was working. So in case you login to server using ssh keys without password, you can try below steps:
Now you will be able to run any sudo commands without password.