Linux environment variable setting method summary (Path/ld_library_path)

Source: Internet
Author: User

Both path and Ld_library_path are variables, and the so-called variables mean that they are assigned by others, and intuition tends to allow us to add and reduce certain paths to the variable itself, which is actually not true. The right thing to do is to modify the configuration file that gives the value of the variable, add a path, or subtract a single line. In the final analysis, variables are only about display, not about what they are intended to display.

Path: The lookup path to the executable program

To view the current environment variables:

Echo $PATH

Set up:

Method One: Export path=path:/xxx but fails after logout

Method Two: Modify the ~/.BASHRC or ~/.bash_profile or system level/etc/profile

1. Add For example export Path=/opt/activepython-2.7/bin: $PATH

2. Source. BASHRC (The source command is also known as a "point command", which is a dot symbol (.).) The source command is typically used to re-execute a newly modified initialization file for immediate effect without having to log off and log back in.

Ld_library_path: Find path for dynamic libraries

Set up:

Method One: Export ld_library_path=ld_library_path:/xxx but fails after logout

Method Two: Modify the ~/.BASHRC or ~/.bash_profile or system level/etc/profile

1. Add For example export path=/opt/activep/lib: $LD _library_path

2. Source. BASHRC (The source command is also known as a "point command", which is a dot symbol (.).) The source command is typically used to re-execute a newly modified initialization file for immediate effect without having to log off and log back in.

Method Three: This is not modified Ld_library_path but the effect is the same as the implementation of dynamic library search,

1. Add a line below/etc/ld.so.conf/usr/local/mysql/lib

2. Save after Ldconfig (the purpose of the Ldconfig command, mainly in the default search directory (/lib and/usr/lib) and dynamic Library configuration file/etc/ld.so.conf listed in the directory, the search for a shareable dynamic link library (format as described above, lib*.so*) to create the connection and cache files required for the dynamic loader (ld.so). The cache file defaults to/etc/ld.so.cache, which holds the list of queued dynamic-link library names.)

Method Three is slightly cumbersome, and the benefit is that the comparison is not restricted by the user.

Linux environment variable setting method summary (Path/ld_library_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.