Ways to view and add path environment variables in Linux

Source: Internet
Author: User

$PATH: determines which directories the shell will look for commands or programs, and the PATH value is a series of directories that Linux searches for and compiles links to when you run a program.

Edit the PATH declaration in the format:

Path= $PATH:<path1>:<path2>:<path3>:--:<pathn>

You can add the specified path yourself, separated by a colon in the middle. When the environment variable is changed, it will take effect the next time the user logs on, and if you want to take effect immediately, execute the following statement:


$source. Bash_profile

Use the Export command to view the path value.

To view the PATH environment variables individually, use:

Echo $PATH

Add path environment variable, available:

Export path= Path: $PATH

View command: Echo $PATH to determine if PATH success was added.
The path of the above method disappears after the terminal is closed. Therefore, it is recommended to change the path by editing/etc/profile, or to change the. BASHRC (ie: ~/.BASHRC) in the home directory.

The second method:

# Vim/etc/profile

At the end of the document, add:

Export path= "directory: $PATH"

Save, exit, and then run:

#source/etc/profile

No error is successful.


Add PATH environment variable, available:

[Root@localhost U-boot-sh4] #export path=/opt/stm/stlinux-2.3/devkit/sh4/bin: $PATH

View again:

[Root@localhost u-boot-sh4]# Echo $PATH
/opt/stm/stlinux-2.3/devkit/sh4/bin:/usr/kerberos/sbin:/usr/kerberos/bin:/usr/local/sbin:/usr/local/bin:/sbin :/bin:/usr/sbin:/usr/bin:/root/bin

Description Add path succeeded.

The path of the above method disappears after the terminal is closed. Therefore, it is recommended to change the path by editing/etc/profile, or to change the. BASHRC (ie: ~/.BASHRC) in the home directory.

instance: adding ~/.composer/vendor/bin to path when using Laravel

$vi. BASHRC

At the end of the file join

Export path= "~/.composer/vendor/bin: $PATH"
$source. BASHRC

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.