abc.py
has to be in the command search path (i.e. in one of the directories specified in the PATH
environment variable). ./abc.py
is an exact path: it executes abc.py
from the current directory (.
).
In the Unix world it is considered a bad practice to have the current directory in the path, since it allows for extremely simple malicious attacks, where a well placed executable named after a common Unix command (or common mispellings thereof) would be inadvertently executed by an unsuspecting user.
E.g. a rather improbable, but most illustrating example is that where an attacker could leave an executable named rm
in /tmp
and wait for a system administrator to attempt to empty the /tmp
directory.
10This is relevant because many times the current directory isn't in the search path, so if you try to run
abc.py
you will get an error. – Javier – 2011-04-13T14:00:46.3807Also, the main reason that people use "./" is that it is considered a security vulnerability to include the current directory in the path of directories to be searched so people usually do not expect the current directory to be searched, and usually do not put . in PATH. – William Pursell – 2011-04-13T14:47:48.050