19

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?

29

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.

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

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 '15 at 7:07
  • May be this stackoverflow question can solve your problem :) – Anonymous Platypus Apr 20 '15 at 7:25

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.