Modify path Path under Linux

Source: Internet
Author: User

1. #PATH = $PATH:/opt/lamp/mysql/bin
with this method, only the current session is valid, meaning that the PATH setting is invalidated whenever the system is logged out or logged off

2. #vi/etc/profile
add path= $PATH in place:/etc/apache/bin (Note: = is not allowed to have any spaces on either side of the equals sign) This method is best, unless you manually force the value of PATH to change, otherwise it will not be changed

However, in general, we do not directly in the face of modification, at the beginning of/etc/profile has such a hint:

# It's not a good idea to the change this file unless you know
# is doing. It ' s much better to create a custom.sh shell script in
#/etc/profile.d/to make custom changes to your environment, as this
# would prevent the need for merging on future updates.

so: Add a customer.sh text file to the/etc/profile.d/directory, open it and typing

Export path= $PATH:/opt/lamp/mysql/bin save exit, source/etc/profile immediate effect, the next landing will also take effect

3. #vi ~/.bash_profile
Modify the path line, add/opt/lamp/mysql/bin to this method is for the user to work

Note: To change path, you must re-login to take effect, the following methods can simplify the work:

If/etc/profile is modified, then the source profile or the Execute Point command is executed after the edit finishes. The value of/profile,path will take 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 the source is in the current Shell process, so we can see the change in path.

In general, the bin directory under the user's working directory will be included in the path, so just put the user's own shell script in the user's Bin directory, do not need to modify the configuration file.

Modify path Path under 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.