Ubuntu 12.04 Precise Pangolin – sudo and the PATH variable

Recently I noticed that a modified $PATH variable – even system-wide by scripts like

export PATH=add_to_path:$PATH

in /etc/profile.d – is not preserved when doing sudo, giving a familiar

sudo: (...) command not found

error message. As discussed here, the reasoning behind this are security measures. A convenient temporary work-around is to set the PATH variable when calling sudo

sudo env PATH=$PATH YOUR_COMMAND

This will give sudo the same PATH environment variable as the calling user.

Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s