tags:

views:

1724

answers:

1

I want add some directory to the $PATH when running sudo, this is a (semi) permanent requirement, not something that needs to be added to the scripts themselves. I notice that Django has managed to do it, (my $PATH when running sudo is "/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/X11R6/bin:/django/django-trunk/django/bin") - so how did it do that?

+1  A: 

I think this should work out if you save it in /root/.bashrc:

export PATH=/www/foo:$PATH

I forget if it's PATH or PYTHONPATH and if it actually matters, this is based on my user's .bashrc:

export PYTHONPATH=/www/django:$PYTHONPATH
meder
Thanks, meder, this did the trick.
simon slingsby
No problem. Don't forget to select an answer so others can know it has been solved :)
meder
+1 for solving the OP's problem.
ire_and_curses
It's not PATH but PYTHONPATH
orwellian
This doesn't work for me. I added the path to /root/.bashrc, then ran "sudo env | grep PATH" and the added path was not present. Perhaps it works for PYTHONPATH, but not for PATH.
Jason R. Coombs
It didn't work for me too. I asked a new question at http://stackoverflow.com/questions/2717043/changed-sudo-path-command-continues-not-being-found
Delirium tremens