mac system environment variables

Default system variables:
PATH=/usr/local/bin:/usr/bin:/bin:/usr/sbin:/sbin

mac Several locations for configuring environment variables:
1. /etc/profile  
global (public) configuration, This file is read when logging in, regardless of the user.

2. /etc/bashrc   
global (public) configuration, this file will be read when the bash shell is executed, no matter what the method is.

3.~/.bash_profile (usually add user-level environment variables in this file)
Each user can use this file to enter shell information dedicated to their own use. When the user logs in, this file is only executed once!

Sometimes accidentally Deleted the environment variable, and vi can't be used. When you need to restore it, first execute it in the terminal window:
PATH=/usr/local/bin:/usr/bin:/bin:/usr/sbin:/sbin
Set the default environment here Yes.
Then use vi to set the environment variable in the above path, and then execute the file, so it is restored.

Guess you like

Origin http://43.154.161.224:23101/article/api/json?id=326491423&siteId=291194637