Ubuntu – Why can’t sudo find a command after I added it to PATH

permissionssudo

I want to add some command to PATH so that I can use them conveniently, such as:

export $PATH = "$PATH:/opt/storm/bin"

but sometimes storm need root authority, but when I use it with sudo, Ubuntu cannot find the command.

sudo storm nimbus

how can I find these command when I use sudo?

Best Answer

You have to add the path to the sudo path.

Run the command sudo visudo

you will see a line like this:

Defaults        secure_path="/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:$

Now add the path of your command here and this should work.

For example:

$ sudo storm
sudo: storm: command not found

Now add the path as above:

$ sudo visudo 

secure_path="......:/opt/storm/bin"

save and exit.

now sudo storm will just work normally.

Note You should also add the path to the default path in /etc/profile.