Where can I add to the ***universal*** path?

I’m a script kiddie of sorts and enjoy writing bash scripts for things, and I keep them in a repository that I synchronize, and on my personal computers I keep it in a home/otherStuff/customBin folder, but…

while I can add it to the .bashrc of every profile that gets tedious, and etc/environment doesn’t seem to work for one reason or another.

(Edit) @steeldriver answered the below portion, but I still need the above question answered.

And the crux of the problem was, when I did "sudo customScript" it behaves like the file isn’t on path, but doing "sudo -i" and then "customScript" does work just fine. How do I fix it?

"Under the default Ubuntu configuration, sudo uses its own secure_path in place of the environment’s PATH – see for example Executable runs without sudo but not with sudo" –
steeldriver

Asked By: Jrome

||

The usual place to put user installed applications (and scripts) is /usr/local/bin.

You only need sudo to copy/sync the scripts to this location.

/usr/local/bin should be in your path, and if executable, scripts can be run by all users.

Answered By: Artur Meinild

You should be able to make it a universal path by adding to the /etc/profile file and also make it add a check.

If you add the following to the bottom of the /etc/profile then when you reboot it should be able to add it to the path universally or globally:

# Check for script directory and add to path
if [ -e /home/otherStuff/customBin ]; then
    PATH=/home/otherStuff/customBin:$PATH
fi
Answered By: Terrance
Categories: Answers Tags: , , , ,
Answers are sorted by their score. The answer accepted by the question owner as the best is marked with
at the top-right corner.