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: 
Secure\_path is your friend, but if you want to exempt yourself from secure\_path just do

```

sudo visudo

```

And append

```

Defaults exempt_group=your_goup

```

If you want to exempt a bunch of users create a group, add all the users to it, and use that as your exempt\_group. man 5 sudoers for more.
the recommended solution in the comments on the OpenSUSE distro suggests to change:

```
Defaults env_reset

```

to:

```
Defaults !env_reset

```

and then presumably to comment out the following line which isn't needed:

```
Defaults env_keep = "LANG LC_ADDRESS LC_CTYPE LC_COLLATE LC_IDENTIFICATION LC_MEASURE    MENT LC_MESSAGES LC_MONETARY LC_NAME LC_NUMERIC LC_PAPER LC_TELEPHONE LC_TIME LC_ALL L    ANGUAGE LINGUAS XDG_SESSION_COOKIE"

```