Linux environment variable $PATH

Source: Internet
Author: User

We know that the instructions for checking the properties of a file ls the full file name:/bin/ls (This is the absolute path), so why is it possible to execute the/BIN/LS command from anywhere? Why is it possible to enter LS in any directory to display some information without saying that the/BIN/LS directive cannot be found? This is because of the environment variable PATH!

When we execute an instruction, such as LS, the system will search for an executable file named LS according to the directory defined by path, and if there is more than one executable file named LS in the directory defined by path, then the first command to search for the same name is executed first!

Echo $PATH

 

PATH (must be uppercase) the contents of this variable are composed of a bunch of directories, each of which is separated by a colon (:), and each directory is in order. Take a closer look at the above output, you can find that both root and Vbird have/bin this directory in the PATH variable, so it is necessary to be able to perform LS lookup anywhere/bin/ls execution!

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.