Why do I need to add "./" to the file name of the executable (command) that executes this directory under Linux.

Source: Internet
Author: User

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.

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.