/ Etc / profile; / etc / bashrc is for all users of the system global variables, only the root user can modify these two files is that they are read-only for general users.
General users want to modify them, you can add sudo before the command is as Root mean execution, such as: sudo vi / etc / profile, and then follow the prompts to enter your password.
So, for the average user, we usually recommend to modify ~ / .bash_profile to set environment variables, which are user-level settings, only to the current user.
Steps:
1, open Terminal (Terminal)
2, input: vi ~ / .bash_profile
3, is provided PATH: exportPATH = "$ PATH: / usr / local / bin / python"
4. Enter :: wq // save and exit vi (note that in vi :)
5, modified with immediate effect: source ~ / .bash_profile
6, see the value of environment variable: echo $ PATH
Note: 1, ~ / .bash_profile There is a point
2, if the value of the new environment variable or modify environment variables, you need to source it to take effect immediately.
If you delete an environment variable, you must enter exit to logout the current shell, and then re-open a new shell and login to take effect