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

Possible Duplicate:
Environment variables when run with 'sudo'

I've added a new folder to my path, but when running the programs (in that folder) with "sudo" it does not work.

When I type

sudo <command-name>

it returns:

sudo: <command-name>: command not found

How do I make it available for sudo?

share|improve this question

marked as duplicate by bodhi.zazen, Jorge Castro, Takkat, htorque, James Mar 7 '12 at 20:26

This question has been asked before and already has an answer. If those answers do not fully address your question, please ask a new question.

up vote 1 down vote accepted

The PATH is located in your ~/.profile, ~/.bashrc, or ~/.bash_profile file. This file is made for your account only.

When you set your PATH, you probably editted /home/yourname/.profile right? Sudo doesnt (as one might think) uses the PATH from /root/.profile instead of /home/yourname/, nor does it always use your own PATH.

The problem is that a couple of variables are overwritten by sudo. Which ones depends on your system. As root, run:

sudo -V

It will tell you if your PATH is used or not. You could then use sudo -E option to overwrite the using of the default PATH. See the description in the manpage about the /etc/sudoers file.

share|improve this answer
Can you please add that as an answer to the link I gave so your answer does not get lost if this question is closed. – bodhi.zazen Mar 4 '12 at 21:46
it returns something that includes the line : Value to override user's $PATH with: /usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/X11R6/bin – MhdSyrwan Mar 4 '12 at 21:54

That's strange. Anyway I think that

sudo /FULL_PATH/program_name

will work.

Another good idea will be to add a symbolic link to it in the /sbin/ directory with

sudo ln -s /FULL_PATH/program_name /sbin
share|improve this answer
is there any way to change the PATH used in sudo ? – MhdSyrwan Mar 4 '12 at 21:11

Not the answer you're looking for? Browse other questions tagged or ask your own question.