Super User is a question and answer site for computer enthusiasts and power users. It's 100% free, no registration required.

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

I am trying to get rid of the password prompt in Ubuntu Linux, during the "su" command. Basically, I need to do something like:

su otheruser

to enable a few of my applications to run in batch mode. However, since it runs in batch, I would like to disable the password prompt.

What I have tried to do is:

sudo visudo
otheruser ALL=(ALL) NOPASSWD: /bin/su 

but this still asks me for the password.

For example, to disable sudo from asking a password, I did:

sudo visudo

and it works fine. However, when I try this with su, it does not work.

Has anyone encountered this problem? Any guidance would be much appreciated.

share|improve this question

migrated from Mar 28 '12 at 12:12

This question came from our site for professional and enthusiast programmers.

after visudo did you try sudo su otheruser ? – dldnh Mar 27 '12 at 16:22
yes, I did, and it asks me for the password! – JohnJ Mar 27 '12 at 16:41
You realize that granting every user permission to switch to any other user with no password is a huge security risk, right? Every account will effectively be root. – Wyzard Mar 28 '12 at 12:22

su is not related in any way to sudo or the sudoers file. It always asks for the target user's password. (Even if it did, you are putting the wrong username in 'sudoers'.)

For batch usage, you can use sudo -u otheruser, along with the NOPASSWD option in sudoers. For example:

$ sudo visudo

JohnJ    ALL=(otheruser) NOPASSWD: /usr/bin/myprogram

$ sudo -u otheruser myprogram
share|improve this answer

Here are two solutions, first you need to know what the "set user bit" is/does. To do that read e.g.

Take care though, because a lot of security hole exists if you dont setup things right, as this is a powerful tool and "with great power comes great responsibility" ;) Note that this tutorial is for traditional systems, if you have ACL (Access Control Lists), you need to give the respective to suid permission.

Solution 1: Security-wise the better one: If you want to su to one or two particular user(s), have one or two files that suid to those users. If you have more users, depending on what you are doing, create a user group, and use the group.

Solution 2: The simplest one sometimes: have the file suid to root. THIS IS ESPECIALLY DANGEROUS, avoid it.

share|improve this answer

Your Answer


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