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

Folks, I'm having an issue with a bash script which runs a particular command as a different user.

The background: Running on a Linux box (CentOS), the script is quite simple, it's starting the hudson-ci application.

declare -r HOME=/home/hudson
declare -r RUNAS=hudson
declare -r HOME=/home/hudson
declare -r LOG=hudson.log
declare -r
declare -r BINARY=hudson.war

su - ${RUNAS} -c "nohup java -jar ${HOME}/${BINARY} >> ${HOME}/${LOG} 2>&1; echo $! > ${HOME}/${PID}" &

This is the abridged version of the script, when run, the script exits with "standard in must be a tty". Any ideas on what I could be doing wrong? I've tried Dr Google and all the advice hasn't helped thus far.

Other reference: Mandriva Linux 'su' bug

share|improve this question
up vote 11 down vote accepted

In your /etc/sudoers file, try commenting out the line that says "Defaults requiretty". There are security implications of doing so, so you might want to instead add this line below:

Defaults:[username] !requiretty

Be sure to use the visudo command to edit this file, rather than a regular text editor.

share|improve this answer
Thanks heaps, that's worked a treat :D – shaond Mar 14 '10 at 20:48
You can also make security admins happier by limiting the scope of your removal of restrictions by specifying the user who can issue a command with no tty. see:… – benvolioT Oct 19 '10 at 19:03
Neither of these worked for me. – Cerin Dec 2 '10 at 22:24
Doesn't /etc/sudoers apply to the sudo tool, not coreutils su? – Felipe Alvarez May 7 '14 at 3:11
Why must you use visudo ? Please expand – 8bitjunkie Nov 17 '15 at 0:25

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.