Configuration of various common environment variables under Linux

Source: Internet
Author: User

 

The various environment variables under the Linux system are implemented by modifying the/etc/profile file. Because it is a system file, you need root permission to modify this file. Therefore, the user must have root privileges to implement the following functions.

Another: Do not easily modify the existing content in the profile file. You should insert a new line at the end of the file if the original content is guaranteed to be unchanged.

1. Path variable paths

When a user executes a command or executable program in a working directory, if the program does not exist under the current path, the system looks for the specified application from the path path list. Do you remember the Java command, ping command? The folders in which these applications are located are contained in a path path.

Modification method: Insert a new line at the end of the profile file, write to export Path={yourpath}: $PATH

Explain this: {Yourpath} here indicates that you want to join a directory in path. For example, if you want to add the/home/jack/apps/directory to PATH, write this: export path=/home/jack/apps/: $PATH

In the expression that is behind the equal sign, multiple paths are separated by colons. Finally, be sure to join $path. This means that several directories have been appended to the original PATH environment variable. The method of obtaining environment variables in a Linux system is the dollar sign $+ variable name. Save the file when you've set it up. Wait, this will not take effect immediately. This setting is global. This record is added to the environment variable path, regardless of the number of users in the current system. So the system must be restarted before it can be really applied. OK, after restarting, enter Echo $PATH in the terminal to see if the new join path has been shown. This example is just a primary literacy, and what is described next will not be so wordy.

2. Add library default load Path Ld_library_path

Export Ld_library_path={yourpath}: $LD _library_path

The purpose of joining this environment variable is to allow the system to load the library from a user-defined directory (a bit like a DLL in Windows). So if you have a software that relies on many libraries, but does not want to destroy the original purity of the system, you can put all the libraries in a folder and then add that folder to the LD_LIBRARY_PATH environment variable.

3. Add gcc default INCLUDE directory C_include_path

Export C_include_path={yourpath}: $C _include_path

If you use GCC to compile your C program, you have installed a third-party C library. You can put the header file in the library into a directory, and then use that directory as the default lookup header file directory for GCC. This way you can add less than one "-i" parameter when compiling, and the compiler will automatically look for the referenced header file from the original directory and the directory you set.

The Include directories commonly used in Ubuntu 10.04 are

/usr/include
/usr/include/c++/4.4
/usr/include/c++/4.4/backward
/usr/include/c++/4.4/i686-linux-gnu
/usr/lib/gcc/i686-linux-gnu/4.4.5/include
/usr/lib/gcc/i686-linux-gnu/4.4/include-fixed
/usr/local/include

4. Add the g++ default INCLUDE directory Cplus_include_path

Export Cplus_include_path={yourpath}: $CPLUS _include_path
The meaning is the same as the one above, except for the g++ compiler.

I'll add it to the article in a timely manner when I touch the new content back. Friends are also welcome to provide them. Thank you, sir.

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.