Detailed description of PATH for adding and deleting environment variables in Linux, environment variable path
Http://blog.csdn.net/pipisorry/article/details/39507699
In Linux, add the/etc/apache/bin directory to PATH:
1. # PATH = $ PATH:/etc/apache/bin
This method is only valid for the current session. That is to say, the PATH setting becomes invalid every time the system is logged out or logged out (terminal is disabled ).
2. # vi/etc/profile
Add PATH = $ PATH:/etc/apache/bin in the appropriate location (Note: = no space is allowed on both sides of the equal sign)
This method is best, unless you manually force modify the value of PATH, it will not be changed
3. # vi ~ /. Bash_profile
Modify the PATH and add/etc/apache/bin.
This method works for users.
Note: to change the PATH, you must log on again to make it take effect. The following methods can simplify the work:
If the/etc/profile is modified, run the source profile (source/etc/profile) or the dot command./profile after editing. The PATH value takes effect immediately.
The principle of this method is to execute the/etc/profile shell script again. Note that if sh/etc/profile is used, sh is executed in the sub-shell process, even if the PATH is changed, it will not be reflected in the current environment, but the source is executed in the current shell process, so we can see the PATH change.
In this way, you will learn how to modify the PATH of the environment variable in Linux.
Additional instructions
Work environment setting file
There are two types of Environment setting files: system environment setting files and personal environment setting files.
1. User work environment setting file in the system:
Login environment setting file:/etc/profile
Non-Logon environment setting file:/etc/bashrc
2. Environment setting file set by the user:
Log on to the Environment setting file: $ HOME/. bash_profile // where environment variables are set
Non-Logon environment setting file: $ HOME/. bashrc // This is the place where the alias is defined
Logon environment: the operating environment after a user logs on to the system.
Non-Logon environment: the user environment used by the user to call the sub-shell.
From: http://blog.csdn.net/pipisorry/article/details/39507699
Ref: http://opsmysql.blog.51cto.com/2238445/665990
How to add a PATH to the PATH environment variable in linux?
1. Global paths available to all users: You can configure global paths by modifying the configuration files:/etc/bashrc and/etc/profile;
Example: vi/etc/profile
Add a line after the end: PATH = THE_SET_GLOBLE_ENV_PATH: $ PATH;
Next line feed: export PATH
If it takes effect immediately: source/etc/profile
2. for common users, you can set your own path: In your home directory:
Ls-a | grep bash
Two files are found:. bashrc and. bash_profile.
You can also modify. bash_profile to configure your personal PATH environment like modifying/etc/profile.
After the modification, if you do not restart it, make it take effect immediately. Do not forget source. bash_profile.
Haha, let's take a look at your modified PATH: echo $ PATH or env !!
Deletes a specified value in the linux environment variable.
Use sed's search and replacement function.
NewPATH = $ (echo $ PATH | sed s #/usr/bin :##)