adding programs to path
I have a load of tools that are kept in the /opt directory. The tools are organised like this: /opt/toolname/tool.sh. My question is, how can I add the tools in my /opt folder to my path, so i can run them from any directory in a terminal.
I have managed to do this with some tools by creating a symlinks in /usr/bin; but with over 200 tools it is a very tedious way of doing things. is there a better way to do this?
You can add the folders to your path using the following command:
You should include this in a shell script that will be run before you open a terminal window (such as .bash_profile in your home folder).
However, since path isn’t recursive, you’ll need to add each individual tool folder.
The only correct way, is to make links in
/usr/local/bin as you described. Because in those folders in
/opt/toolname there are normally many other files, not just executables. I would be grubby. Anyway, adding
/opt/*/ to the
$PATH variable would not work.
If you have a list of the full paths to those binaries, you could generate the links scriptually.
There are many ways to do it:
- Make a symlink in
sudo cp -s /opt/toolname/tool.sh /usr/bin/[unique_Toolname]
- Combine the above but use