For Mac, you can set the location of the environment variable, view and add the PATH environment variable. For Mac startup and file loading location (you can set the environment variable), you must first know what Shell your Mac OS X is, run echo $ SHELL. If the output is csh or tcsh, you use C Shell. If the output is bash, sh, and zsh, you may use a variant of the Bourne Shell. Before Mac OS X 10.2, the default value is C Shell. The default value after Mac OS X 10.3 is the Bourne Shell. If it is a Bourne Shell. Then you can add the environment variable you want to add to the. profile or. bash_profile under your main directory. If there is no relationship, add it. If no one is generated. 1./etc/profile (it is recommended that this file be not modified) Global (public) configuration, no matter which user, the file will be read at login. 2./etc/bashrc (generally adding system-level environment variables to this file) Global (public) configuration. During bash shell execution, the file will be read in any way. Here, I add aliases for mysqlstart, mysql, and mysqladmin commands to ensure that each user can use these three commands. 3 .~ /. Bash_profile (generally add user-level environment variables to this file) (Note: in Linux. bashrc while Mac is. bash_profile) If bash shell is executed in the login mode, the file will be read. This file is only executed once! By default, it sets some environment variables. Here I am: Set the terminal color, here I am: Set the command alias ll = 'LS-la' I am here: Set the environment variable: export PATH =/opt/local/bin:/opt/local/sbin: $ path mac modify the hosts file sudo vi/etc/hosts in linux to view and add the PATH environment variable PATH in the format of: PATH = $ PATH: <PATH 1 >:< PATH 2>: <PATH 3>: ------: <path n>, separated by a colon. Add PATH environment variable: export PATH =/opt/STM/STLinux-2.3/devkit/sh4/bin: $ PATH view PATH environment variable: echo $ PATH/usr/kerberos/sbin: /usr/kerberos/bin:/usr/local/sbin:/usr/local/bin:/sbin:/bin:/usr/sbin:/usr/bin: /root/bin operation example: Modify the PATH by editing the Startup File, and add vim/etc/profile at the end of the document: export PATH = "/opt/STM/STLinux-2.3/devkit/sh4/bin: $ PATH" Save, exit. To take effect immediately, run the following command: If no error is reported for source/etc/profile, the operation succeeds. If you want to take effect immediately, you can execute the following statement: source. bash_profile (this is the file name) after the environment variable is changed, it will take effect the next time you log on.