Ask Ubuntu is a question and answer site for Ubuntu users and developers. 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

OK, I'm having a bit of an issue with PATH and running a process as another user under Ubuntu.

First, we check where the bin is:

root@host:~# whereis start-stop-daemon
start-stop-daemon: /sbin/start-stop-daemon /usr/share/man/man8/start-stop-daemon.8.gz

ok, /sbin/start-stop-daemon so ti's in /sbin. then we check path as a user we want to run the app:

root@host:~# su wojtek -c "echo $PATH"

root@host:~# su -l wojtek -c "echo $PATH"

in both cases the PATH is exactly the same (ie. in normal su and with full login) yet there is a distinction when we actually want to run the command:

root@host:~# su wojtek -c "start-stop-daemon"
bash: start-stop-daemon: command not found

root@host:~# su -l wojtek -c "start-stop-daemon"
start-stop-daemon: need one of --start or --stop or --status
Try 'start-stop-daemon --help' for more information.

Can somebody try to explain where the difference comes from? Because for me there shouldn't be any error as there is no difference in PATH thus $start-stop-daemon for a given user should work either way...

also - if I switch to different user ($su user and $su - user) then $start-stop-daemon in both cases...

what am I missing?

share|improve this question
Why are you logged in as root? – Alvar Jun 19 '13 at 12:21
up vote 1 down vote accepted

The path appears to be the same in your two statements because $PATH has been expanded within the double quotes before being passed to the su command.

Try it with single quotes and I think you'll be pleasantly surprised:

su wojtek -c 'echo $PATH'


su -l wojtek -c 'echo $PATH'
share|improve this answer
Also read the output of the second command more carefully, start-stop-daemon was found, you need to provide an argument. See also – bodhi.zazen Jun 19 '13 at 15:51

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.