Can anyone please explain the exact work of these in /etc/sudoers
? (I've done some research, so please don't share any links)
I want to add myself (member of sudo
) to execute a command without password.But it's again asking for password.
# User
root ALL=(ALL:ALL) ALL
myself ALL=(ALL:ALL) NOPASSWD:/bin/apt update, PASSWD:/bin/apt install*
# Groups
%sudo ALL=(ALL:ALL) ALL
I pretty much stole it from here: Is it possible to give sudo access to only a particular command?
And add that to the file:
Don't know how to make this a one-liner, though. Hope that helps.
The order of configuration lines has significance in the sudoers file: the last applicable line wins.
If user
myself
is a member of thesudo
group, all commands issued by that user will always match the%sudo ALL=(ALL:ALL) ALL
line. As it has noNOPASSWD:
flag, password will be asked.The fix is to arrange the
/etc/sudoers
configuration lines in the order of increasing specificity:When this order is used, if user
myself
runssudo apt update
, it will match the last line with theNOPASSWD:
flag.This is my first post on askubuntu but i am pretty sure you could do it like that create a file with your
username
in/etc/sudoers.d/
with:You can simple add the next line to your sudoers file:
Remember to separated with commas all commands you want to be executed by user with out password promp.