0

For example, I can run ln, nano, and programs I installed over apt like sl or worms without having to give the full path. However, when I build a program/package/software manually/using make/using something else, I have to invoke it using the full path, in my case ~/ghc/bin/ghc. How do you tell bash, or for that matter, sh, which names exist?

I know how to do this on Windows, but as far as I know, there's no equivalent of %PATH% in Linux/Unix/Ubuntu (in my case).

schuelermine
  • 1,537

1 Answers1

2

There is - the variable is called $PATH.

You may make a program globally accessible by copying it to any path that's listed under $PATH, such as /usr/bin or /usr/local/bin or /bin.

The recommended place to add your own custom binaries is /usr/local/bin though.

You may also add new directories to the $PATH by overwriting the variable in your shell start script (in ~/.bashrc, or ~/.bash_profile):

export PATH="$PATH:/usr/local/myfolder/bin"

You can find out more about the recommended meanings for UNIX filesystem paths here.

boxmein
  • 136