[Ubuntu] [Linux] Changing path path

Source: Internet
Author: User

1. What is an environment variable (PATH)

In Linux, when the command is executed, the system will follow the path's settings to search for execution files under the paths defined by each path, and the first files to be searched are executed first.

We know the instructions for checking the properties of a file ls full file name:/bin/ls (This is the absolute path), then you will not find it strange: "Why can I execute the/bin/ls command anywhere?" "Why do I enter LS in any directory to show some information without saying that I can't find the/bin/ls directive?" This is due to the help of the environment variable PATH!

When we execute a command, for example, "LS" is good, the system will follow the path of the directory defined by each path to search for the executable file named LS, if the directory defined in path contains more than one executable file named LS, then the first to search for the same name command is executed first! (From: "The bird's Linux private dish")

2. How to change path

A. directly modify the $PATH values:

Echo // View the configuration path for the current path Export PATH // Add the required configuration path to the $path  equals sign must not have spaces // configuration results can be viewed through the first sentence command. 

Effective Method: Immediate effect

Validity period: temporary changes, only valid in the current terminal window, when the current window is closed will restore the original Path Configuration

User limitations: only for the current user

b . by modifying the .BASHRC file: file under the root directory )

vi. BASHRC   // edit. bashrc file
// add on the last line:

export PATH= $PATH:/xxx/xxx// xxx/xxx The environment variable you want to add the address equals no space on either side

Effective method: (There are the following two kinds)

.. Close the current terminal window and reopen a new terminal window to take effect

.. Enter the source. BASHRC " command, effective immediately

Validity period: permanently valid

User limitations: only for the current user

C. by modifying the profile file: ( profile file in / etc directory)

VI // Edit Profile // add on the last line: export PATH= $PATH:/xxx/xxx

Effective Method: System Restart

Validity period: permanently valid

User limitations: for all users

d. by modifying Environment Files: ( Environment file in / etc directory)

VI // Edit Profile in Path=/ Add ":/xxx/xxx"

Effective Method: System Restart

Validity period: permanently valid

User limitations: for all users

[Ubuntu] [Linux] Changing path path

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.