This question already has an answer here:

For instance, I have installed java and can just run java ... but if I create a shell script for instance, I have to run ./script.sh.

Why is this? What does the ./ signify?

marked as duplicate by slhck Apr 23 '13 at 16:38

This question has been asked before and already has an answer. If those answers do not fully address your question, please ask a new question.


When an executable is not in the PATH , you need to specify the path explicitly. ./ is a "relative" path specifier: "starting from here (.) go "no further" (/). If you add the current directory to your PATH environment variable and issue rehash command, you will no longer need it.


When you run a command, the shell searches the PATH variable (or some hash table, depending on the shell#) where to find the executable. But usually the current working directory (.) isn't included. So, you need to tell the shell where to find your script by prepending ./ as explained by Floris.

The purpose of that default setting is, that you are saved from accidentally executing a script (in the current dir) which is named e.g. rm instead of the expected command in /bin. This is especially crucial for root, because the local script can behave completely different as you'll expect it!

# I wrote a little bit more about hash tables in this answer.


Current directory is not normaly in PATH, so commands will not lookup from current directory by default

  • 2
    Just as extra information: There is a reason why it is not in your path by default, and why you should always put it last if you add it. (Imaging me having a program called ls or dir in my homedir. If you visit my homedir ans try to list the contents then you really want the system file, not the one in my homedir). – Hennes Apr 23 '13 at 15:58

java is in your $PATH variable so that is why it is found and executed. ./ tells the command line to use the file in your current directory which is usually not on the PATH.

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