1

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?

MhdSyrwan
  • 301

2 Answers2

2

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
dadexix86
  • 6,616
1

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.

xatr0z
  • 125
  • 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. – Panther Mar 04 '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 04 '12 at 21:54