Ubuntu – Sudo requires password after adding user to sudoers

passwordpermissionssudouser-management

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

Best Answer

You should use NOPASSWD option

aman ALL=(ALL) NOPASSWD:ALL

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.