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?


3 Answers 3


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 


save and exit.

now sudo storm will just work normally.

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

  • Thanks a lot for this one. It helped and I learned from that!
    – darbehdar
    Oct 21, 2015 at 13:17

I think you have created the alias in the user level. That's why the shortcuts are available at the user level only.

You should add that alias command line to .bashrc file in /root folder and not in /home/user/.bashrc(this .bashrc file belongs to user account not root).

So that you can use your alias command directly in shell when logged in as root.

  • 1
    what about /etc/profile? I add export $PATH = "$PATH:/opt/storm/bin" in this file, I think this is global, but I still cannot find this command
    – roger
    Apr 20, 2015 at 7:07
  • May be this stackoverflow question can solve your problem :) Apr 20, 2015 at 7:25

@Maythux explained what is the secure path where sudo searches for executables

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

you can add the path directly to the list as the answer suggests, but the better and right way is to create an symbolic link unde /usr/bin

sudo ln -s -f  /opt/storm/bin/storm /usr/bin/storm

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .