Modifying the path method of Linux

Source: Internet
Author: User

There are three ways to modify the path of Linux (add a user's path to paths):

Method One: Enter directly on the command line: Export path= $PATH:/etc/apache/bin. This method is only valid for the current session, meaning that the path setting restores the original settings whenever the system is logged out or logged off.

Method Two: Modify the/etc/profile file. Add path= $PATH at the appropriate location in the/etc/profile file:/etc/apache/bin (Note: = cannot have any spaces on either side of the equals sign). This approach is best unless you manually force the value of path to be modified. Otherwise it will not be changed. In the file to add the path, I test the result is only to put the variable $path to the front, put in the back there may be problems, why have problems do not know.


Method Three: Modify the. Bash_profile:vi ~/.bash_profile in the user directory to add the paths that the user wants to add to the path behind the path. This method only works for the user. Note: If you change the path using the method of modifying the profile, you must log in again to take effect.

The following methods are not valid and can be executed after re-login ... Self-testing possible
Work: If/etc/profile is modified, then the edit ends with the source profile or the Execute Point command: The value of./profile,path takes effect immediately. The principle of this method is to execute the/etc/profile shell script again, note that if the use of sh/etc/profile is not possible, because SH is executed in the child shell process, even if the path changes will not be reflected in the current environment, But source is executed in the current shell process, so we can see the change in path.

Modifying the path method of Linux

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.