The path is an environment variable that holds the path to the executable file (usually containing multiple paths, separated by a colon ":" between the paths). When executing an executable (command), Linux takes precedence over the path saved in the PATH environment variable to find it. Use export $PATH
the command to view the contents of an environment variable.
Second, "." Represents the current directory, and the default search path for Windows/dos (that is, the PATH environment variable) has the current directory, so no addition is required. In fact, the same effect is added. Because there is no current directory in the default search directory for Linux, you should add a path if you need to execute the program in the current directory.
Third, theoretically, if you want the file under the current directory to be run without adding "./", simply add "./" to the path parameter, as follows:
export PATH=$PATH:./
However, this is not usually recommended, and is based on security considerations. If the System Manager is in a directory where there are executable files, and the file has a problem, an unpredictable problem occurs when it is executed. For example: Any user to/TMP has the W permission, if a user in/TMP added the LS this file, and the file content is as follows:
/usr/sbin/useradd -m adm0/bin/ls
At the same time, when the path is set to export PATH=./:$PATH
, when Root enters/tmp and executes LS, the/tmp/ls is prioritized instead of the system default/bin/ls, so that a user adm0 is unknowingly added. Therefore, even if you want to add the current directory to the path parameter, export PATH=$PATH:./
the security will be better export PATH=./:$PATH
.
Why do I need to add "./" to the file name of the executable (command) that executes this directory under Linux.