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

enter image description here

Note:- When I execute whoami command terminal shows "aman"

Below is the image shows me as i am administrator enter image description here

  • The command is ystemctl restart network-manager.service without "root" at the end. What you want to do is a tremendous bad use of privilege separation which is here to protect your system. – kcdtv Feb 22 '18 at 15:59

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 after aman ALL=(ALL:ALL) in /etc/sudoers

(the line would look like aman ALL=(ALL:ALL) NOPASSWD:ALL)

see here

| improve this answer | |
  • thanks for reply but this also not works, ubuntu still aks me for password. – Anand Suthar Feb 22 '18 at 16:13
  • weird ... I just tried and it worked for me – Félicien Feb 22 '18 at 16:38

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:

aman     ALL=NOPASSWD:/bin/systemctl

It is safer that way.

| improve this answer | |
  • thanks for reply but this also not works, ubuntu still aks me for password. – Anand Suthar Feb 22 '18 at 16:12

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.