Linux--environment variables

Summary

Add the directory path of the executable file to the environment variable, and the user can execute the program at any location in the terminal

classification

  • By cycle
    • Permanent: modify the configuration file
    • Temporary: export variable name = variable value, closing the terminal is invalid
  • By scope
    • System: modify the /etc/profile file
    • User: modify ~/.bash_profile and
      restart the terminal or run source+file name to take effect immediately

Configuration file execution order

/etc/profile
/etc/paths
~/.bash_profile
~/.bash_login
~/.profile
~/.bashrc

MAC

problem

  • .Bash_profile fails under MAC

the reason

MAC defaults to zsh as the default shell, and starts .zshrc as the configuration file

method

Add at the end of .zshrc

if [ -f ~/.bashrc ]; then
   source ~/.bashrc
fi

reference

Detailed explanation of environment variables

Guess you like

Origin blog.csdn.net/weixin_43848079/article/details/110820643