Server Fault is a question and answer site for system and network administrators. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

How can passwordless sudo access be setup on either RHEL (Fedora, CentOS, etc) or Ubuntu distributions? (If it's the same across distros, that's even better!)

Setting: personal and/or lab/training equipment with no concern for unauthorized access (ie, the devices are on non-public networks, and any/all users are fully trusted, and the contents of the devices are "plain-vanilla").

share|improve this question
The answer from @Richipal is actullay the one working best with the least effort: it seems sudoers rules apply in reverse order. – a1an Jun 4 '15 at 12:27
up vote 87 down vote accepted

EDIT thanks to medina's comment: According to the man page, you should be able to write

ALL            ALL = (ALL) NOPASSWD: ALL

to allow all users to run all commands without a password.

For reference, I'm leaving my previous answer:

If you add a line of the form

%wheel         ALL = (ALL) NOPASSWD: ALL

to /etc/sudoers (using the visudo command, of course), it will let everyone in the group wheel run any commands without providing a password. So I think the best solution is to put all your users in some group and put a line like that in sudoers - obviously you should replace wheel with the actual group you use.

Alternatively, you can define a user alias,

User_Alias     EVERYONE = user1, user2, user3, ...

and use that:


although you would have to update /etc/sudoers every time you add or remove a user.

share|improve this answer
Doesn't ALL work rather than * to specify all users? See the example in sudoers(5). – medina Jul 15 '10 at 10:58
@medina: so it does, I missed that when I was reading the man page. I'll edit. – David Z Jul 15 '10 at 17:26
under Ubuntu, creating a file under /etc/sudoers.d and put these entries in it then it will stop you having to edit sudoers – Xetius Oct 28 '12 at 20:18

I tried the solutions above to no avail. The following solution worked for me Edit the /etc/sudoers file and add the following line


The key is to add it after the last line which says

#includedir /etc/sudoers.d
share|improve this answer
// , This looks like the better way to do it, especially when certain applications will add their own rules for system users, Richipal. More info on sudoers.d: – Nathan Basanese Aug 27 '15 at 17:18
// , Would you be willing to add some of the diagnostics from Gearoid Murphy to your answer? – Nathan Basanese Aug 27 '15 at 17:19

I tried all the answers on this page, with no useful results. Eventually I figured it out, use this command to list your sudo rights:

sudo -l

This should give you an output like this:

User gmurphy may run the following commands on this host:
    (root) NOPASSWD: ALL
    (ALL) ALL

It shows that I'm configured with root privileges but that I'm still part of a group (admin) matched to a sudo rule which expects the password ("(ALL) ALL"). This was forcing sudo to prompt me. The rule in question was the admin users:

# Members of the admin group may gain root privileges
%admin ALL=(ALL) ALL

Once I commented this out, I was able to sudo without password. I hope this is of use to someone else.

share|improve this answer
Ahhh, thanks! This was driving me nuts... in my case, my user was part of the "sudo" group as well as "admin" (which I created), and the permissions on each were mis-matched, as they were in your case. Now this stuff works! :) – neezer May 6 '12 at 22:28
Commenting a line out is a blunt instrument. You may be interested to hear that "sudo reads the sudoers file and applies permissions in order from top to bottom. So the last line in the file will overwrite any previous conflict" according to -- and this worked for me. – David James Jan 15 '13 at 4:08

Within /etc/sudoers there's an example of just that towards the bottom of the file:

## Same thing without a password
# %wheel        ALL=(ALL)       NOPASSWD: ALL
share|improve this answer
that sample wasn't in mine - but thanks! – warren Oct 1 '12 at 2:39
Like your succinct answer – ShadowGiraffe Jul 21 '15 at 1:07

There is another way to do it without touching the sudoers file.

  • Edit /etc/pam.d/su and uncomment the line below:

    auth           sufficient trust use_uid
  • Add the user to the wheel group.

share|improve this answer

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

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