Bashrc, bash_profile, and/etc/profile
Recently, applications that can run in shell cannot be run by double-clicking the app. The reason is that the environment variable is faulty.
In Unix-like systems, there are generally three Bash configuration files:
- ~ /. Bashrc configuration file used by the current user
- ~ /. Bash_profile configuration file used by the current user
- /Etc/profile environment configuration files inherited by all users
We need to figure out/etc/profile ,~ /. Bash_profile and ~ /. Bashrc file loading sequence.
Generally ~ /. Bash_profile> ~ /. Bash_rc>/etc/profile, that is, if bash_profile is not found, use/etc/profile if bashrc is not found.
Interested can refer to this blog: http://blog.galeo.me/post/23467503436/path-environment-variable-on-mac-os-x-emacs-app
The. bash_profile file is read in the shell of MacOSX, but the. bashrc file does not have to be read. Two configurations are also a headache, but stackoverflow provides a solution.
Terminal opens a login shell. This means ,~ /. Bash_profile will get executed ,~ /. Bashrc not. The solution on most systems is to „ require "~ /. Bashrc in ~ /. Bash_profile: Just put this snippet in your ~ /. Bash_profile:
[[ -s ~/.bashrc ]] && source ~/.bashrc
Bashrc, bash_profile, and/etc/profile