This question already has an answer here:
- Why do we use “./” to execute a file? 4 answers
@user-123:~$ Downloads/execfile-3.4/execfile @user-123:~$ @user-123:~$ cd Downloads/execfileparentdir-3.4/ @user-123:~/Downloads/execfileparentdir-3.4$ execfile execfile: command not found @user-123:~/Downloads/execfileparentdir-3.4$ ./execfile @user-123:~/Downloads/execfileparentdir-3.4$
What's exactly the reason of using
Note that I'm not asking about the functionality of
./. In other words, I wanted to know why in order to run an executable file from terminal it requires the address from current directory to the given file? Why when we are in current directory like the way that the terminal behaves in other cases behave and just recognize the file name automatically so that we run it by just typing the file name instead of putting and
./ behind it?
One reason might be the security and preventing the user to accidentally execute another (probably malicious) file. That however is a very credible reason to do so but aren't they sacrificing the consistency of a rule for the sake it? And aren't other ways to handle this problem and not make an exception in a unified rule (the prediction of the file names in current dir)? This may sound like a trivial exchange but I want to be sure if it's the tiniest one.