View and add PATH environment variables in Linux

Source: Internet
Author: User

View and add PATH environment variables in Linux

$ PATH: determines which directories The shell will look for commands or programs. The PATH value is a series of directories. When you run a program, Linux searches for compilation links under these directories.

Edit your PATH declaration in the following format:

PATH = $ PATH: <PATH 1 >:< PATH 2 >:< PATH 3 >:------: <path n>

You can add the specified path by yourself, separated by a colon in the middle. After the environment variable is changed, it will take effect the next time you log in. If you want to take effect immediately, you can execute the following statement: $ source. bash_profile

Note that it is best not to put the current PATH "./" in the PATH, which may be subject to unexpected attacks. After that, you can view the current search PATH through $ echo $ PATH. In this way, you can avoid frequent startup of programs outside the shell search path.

Use the export command to view the PATH value

[Root @ localhost u-boot-sh4] # export
Declare-x CVS_RSH = "ssh"
Declare-x DISPLAY = ": 0.0"
Declare-x G_BROKEN_FILENAMES = "1"
Declare-x HISTSIZE = "1000"
Declare-x HOME = "/root"
Declare-x HOSTNAME = "localhost"
Declare-x INPUTRC = "/etc/inputrc"
Declare-x LANG = "zh_CN.UTF-8"
Declare-x LESSOPEN = "|/usr/bin/lesspipe. sh % s"
Declare-x LOGNAME = "root"
Declare-x LS_COLORS = "no = 00: fi = 00: di = 00; 34: ln = 00; 36: pi = 40; 33: so = 00; 35: bd = 40; 33; 01: cd = 40; 33; 01: or = 01; 05; 37; 41: mi = 01; 05; 37; 41: ex = 00; 32 :*. cmd = 00; 32 :*. exe = 00; 32 :*. com = 00; 32 :*. btm = 00; 32 :*. bat = 00; 32 :*. sh = 00; 32 :*. csh = 00; 32 :*. tar = 00; 31 :*. tgz = 00; 31 :*. arj = 00; 31 :*. taz = 00; 31 :*. lzh = 00; 31 :*. zip = 00; 31 :*. z = 00; 31 :*. Z = 00; 31 :*. gz = 00; 31 :*. bz2 = 00; 31 :*. bz = 00; 31 :*. tz = 00; 31 :*. rpm = 00; 31 :*. cpio = 00; 31 :*. jpg = 00; 35 :*. gif = 00; 35 :*. bmp = 00; 35 :*. xbm = 00; 35 :*. xpm = 00; 35 :*. png = 00; 35 :*. tif = 00; 35 :"
Declare-x MAIL = "/var/spool/mail/root"
Declare-x OLDPWD = "/root"
Declare-xPATH = "/usr/kerberos/sbin:/usr/kerberos/bin:/usr/local/sbin:/usr/local/bin:/sbin:/bin: /usr/sbin:/usr/bin:/root/bin"
Declare-x PWD = "/opt/STM/STLinux-2.3/devkit/sources/u-boot/u-boot-sh4"
Declare-x SHELL = "/bin/bash"
Declare-x SHLVL = "1"
Declare-x SSH_ASKPASS = "/usr/libexec/openssh/gnome-ssh-askpass"
Declare-x TERM = "xterm"
Declare-x USER = "root"
Declare-x XAUTHORITY = "/root/. xauthkSzH7b"
 
View the PATH environment variables separately. Available:
 
[Root @ localhost u-boot-sh4] # echo $ PATH
/Usr/kerberos/sbin:/usr/kerberos/bin:/usr/local/sbin:/usr/local/bin:/sbin:/bin:/usr/sbin: /usr/bin:/root/bin
 
Add the 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
 
The PATH is successfully added.
 
The PATH of the above method disappears after the terminal is closed. Therefore, we recommend that you modify the PATH by editing/etc/profile, or change the. bashrc (that is, ~) in the home directory :~ /. Bashrc ).
 
Method 2:
 
# Vim/etc/profile
 
At the end of the document, add:
 
Export PATH = "/opt/STM/STLinux-2.3/devkit/sh4/bin: $ PATH"
 
Save, exit, and run:
 
# Source/etc/profile
 
If no error is reported, the operation is successful.

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.