Mac Introduction (vii)--Environment variable path analysis

Source: Internet
Author: User

 first, we need to understand1>mac generally uses bash as the default shellthe environment variables of the 2>MAC system are loaded in the following order:1, System-level/etc/profile/ETC/BASHRC/etc/paths2, user-level~/.bash_profile (for Mac)~/.bash_login~/.profile~/.BASHRC (for this Linux)Load rule:<1>/ETC/PROFILE,/ETC/BASHRC and/etc/paths are system-level, and the system boot will load<2>~/.bash_profile, ~/.bash_login, ~/.profile is the current user-level environment variable. Read in the previous orderIf the ~/.bash_profile file is present, then the next two files are ignored and not read.If the ~/.bash_profile file does not exist, the subsequent two files are read sequentially<3>~/.BASHRC does not have the above rule, it is loaded when the bash shell is opened.  3>sudo vim ~/.bash_profile, if not specified, the syntax for setting path is:#中间用冒号隔开export path= $PATH: <path 1>:<path 2>:<path 3>:------: <path n>after the general environment variable is changed, the restart takes effect. If you want to take effect immediately, you can execute the following statement: $ source corresponding file  Example Analysis mac comes with git and PHP, I've installed git and php70 myself with brewHowever, in the absence of configuration environment variables git version is Mac, the PHP version is brew The specific analysis is as followsfirst of all clear, according to the principle of first-come, first found will not continue the situation inside the 1>cat/etc/paths2> me into the/usr/local/bin folder, enter the command LS php* and LS git* separately, and then view the version3> We enter the/usr/bin folder under the command LS php* and LS git* respectively, and then view the version4> We continue to find out where the brew-installed git command which gitSummary: First in the/usr/local/bin search, and then in the/usr/bin search, it can be found that why my PHP is installed with the brew and Git is the native If we want to choose the correct version, then add the following in the ~/.bash_profile, the version is right (note that the $path is placed in the back, will be the path you write to the top of the final path)export Path=/usr/local/cellar/git/2.10.2/bin: $PATHExport path= "$ (Brew--prefix homebrew/php/php70)/bin: $PATH"export path= "/usr/local/bin:/usr/local/sbin: $PATH" input $path 

Mac Introduction (vii)--Environment variable path analysis

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.