I want to run sudo as a user after changing to them from root without asking for their password or changing any settings.

Step 1: change to user, from root

server:~#su joseph

Step 2: run sudo on command as that user

joseph@server:/$ sudo vim test.txt

Here I get the prompt for password.

[sudo] password for joseph:

I want to be able to bypass this prompt without having to change the users sudoers settings.

Is this possible?

1 Answer 1


yes, that is possible. provided that user josephaccount is allowed to use sudo command, add NOPASSWD tag on /etc/sudoers file.

it may look like this:

joseph ALL = NOPASSWD: /bin/vim

see man 5 sudoers for more info

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.