Mac system environment variable settings

Source: Internet
Author: User

Mac system environment variable settings recently used Apple notebook, downloaded a rar decompression software, is a command line program, must be added to the system environment variables. Search online and add it ~ /. Bash_profile file, but I have read it. I don't have this file on my computer, but there is ~ /. Profile (these files are hidden files, which can be viewed through ls-a) file. Add the Shell code export PATH =/Users/apple/apps/rar to this file: $ PATH is a typical value assignment statement. $ PATH is an existing environment variable string, because each PATH added to the environment variable is separated by a colon, add the path of rar software/Users/apple/apps/rar to the environment variable. Run the echo $ PATH or printenv PATH command to display the following information: Txt code/Users/apple/apps/rar:/opt/local/bin:/opt/local/sbin: /usr/bin:/usr/sbin:/usr/local/bin: /usr/X11/bin: the newly added path is added to the beginning of the environment variable. I have studied the environment variables of the Mac system. The loading sequence is:/etc/profile/etc/paths ~ /. Bash_profile ~ /. Bash_login ~ /. Profile ~ /. Bashrc of course,/etc/profile and/etc/paths are system-level, which will be loaded when the system starts. The following are the environment variables of the current user level. The last three are read in the previous and subsequent order. If ~ /. Bash_profile file exists, then the following files will be ignored and not read. If ~ /. Bash_profile file does not exist, so it reads the following files accordingly .~ /. Bashrc does not have the above rules. It is loaded when bash shell is opened. It is worth mentioning that in these files, the/etc/paths file does not use the export method to add environment variables, the path of each line in its file content will be added to the environment variable. For example, view the content displayed in this file on my computer: cat/etc/paths: txt code/usr/bin/usr/sbin/usr/local/bin. The environment variables are printed on the paths, they are added to this file.

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: 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.