Question: This is the `PATH` variable without sudo:

```
$ echo 'echo $PATH' | sh 
/opt/local/ruby/bin:/usr/bin:/bin

```

This is the `PATH` variable with sudo:

```
$ echo 'echo $PATH' | sudo sh
/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/X11R6/bin

```

As far as I can tell, `sudo` is supposed to leave `PATH` untouched. What's going on? How do I change this? (This is on Ubuntu 8.04).

UPDATE: as far as I can see, none of the scripts started as root change `PATH` in any way.

From `man sudo`: 

> 
> To prevent command spoofing, sudo
>  checks ``.'' and ``'' (both denoting
>  current directory) last when searching
>  for a command in the user's PATH (if
>  one or both are in the PATH). **Note,
>  however, that the actual PATH
>  environment variable is not modified
>  and is passed unchanged to the program
>  that sudo executes.**
> 
> 
>

Answer: 
Just comment out "Defaults env\_reset" in /etc/sudoers
Er, it's not really a test if you don't add something to your path:

```

bill@bill-desktop:~$ ls -l /opt/pkg/bin
total 12
-rwxr-xr-x 1 root root   28 2009-01-22 18:58 foo
bill@bill-desktop:~$ which foo
/opt/pkg/bin/foo
bill@bill-desktop:~$ sudo su
root@bill-desktop:/home/bill# which foo
root@bill-desktop:/home/bill# 

```