How to modify the PATH of the environment variable in Centos

Source: Internet
Author: User
The computer brain is essential to the operating system. However, Linux is developing very rapidly and is catching up with Microsoft. Here we will introduce the knowledge of Linux, so that you can learn how to use Linux. For example, to add the/etc/apache/bin directory to the PATH, there are three methods: 1. # PATH = $ PATH:/etc/apache/bin this method is only valid for the current session. that is to say, the PATH setting will expire after the system is logged out or logged out.

The computer brain is essential to the operating system. However, Linux is developing very rapidly and is catching up with Microsoft. Here we will introduce the knowledge of Linux, so that you can learn how to use Linux. For example, to add the/etc/apache/bin directory to the PATH, there are three methods:

1. # PATH = $ PATH:/etc/apache/bin
This method is only valid for the current session. that is to say, the PATH setting will expire after the system is logged out or logged out.

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 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.

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.