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

In Ubuntu Lucid Lynx, I'm trying to do

su -l user -c " args"

where is an executable bash script on the PATH set in ~user/.bashrc. Unfortunately, this fails because it can't find If I su -l user and manually type args at the command line, it works fine. The PATH augmentation is done in ~user/.bashrc and appears to work whether or not I su with -l interactively, but it doesn't appear to work when I specify the command.

Any idea why this is, and how I can get around that?

share|improve this question

It's starting the shell as a non-interactive login shell so it processes ~/.profile and not ~/.bashrc. You can set your PATH in that file or do it in a common file that both of them source. Some people/distributions set one startup file to source the other one, but I don't recommend this.

From man bash:

When bash is invoked as an interactive login shell, or as a non-interactive shell with the --login option, it first reads and executes com‐ mands from the file /etc/profile, if that file exists. After reading that file, it looks for ~/.bash_profile, ~/.bash_login, and ~/.profile, in that order, and reads and executes commands from the first one that exists and is readable. The --noprofile option may be used when the shell is started to inhibit this behavior.

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.