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.