Environment variables for mac

a.  /etc/profile

b.  /etc/paths

c.  ~/.bash_profile

d.  ~/.bash_login

e.  ~/.profile

f.  ~/.bashrc

Wherein a and b are system level, the system will start loading, the remaining user-level

c, d, e read from front to back in order, if c file exists, the file will be later ignored several read, so

f there is no such rule, he is open when the bash shell loaded

It proposed to add an environment variable in the c

Use the following command to open the user login password is password .bash_profile

sudo vim ~/.bash_profile

 Add a command like

export MAVEN_HOME=/usr/local/apache-maven-3.6.0
export PATH=$PATH:$MAVEN_HOME

Save and exit vim

Use the following command for the changes to take effect

source ~/.bash_profile

Use echo $ PATH can see all over the path to add

Or use of echo + custom name (such as $ MAVEN_HOME) a ​​view of a single set of environment variables

In the mac in our environment are added to the next PATH path, when the system is running will go directly to the / usr / libexec / path_helper this document, the contents of which it is we set the PATH environment variable, so we set the PATH environment variable by to set

Guess you like

Origin www.cnblogs.com/yanguobin/p/11527496.html