Summary of how to add environment variables in linux

Source: Internet
Author: User

Linux environment variable adding method summary linux environment variables with no double quotation marks, or variables do not need to be included {} is not sensitive, a small look at the profile file, it seems that if the system finds that the variables do not have quotation marks, it is automatically added. However, the $ symbol must be added before the variable. It is similar to perl three methods for adding environment variables. During the use of jena in fedora, I tried: 1. Use the export command directly: for example: export PATH = $ PATH:/home/lm/apache-jena-2.7.4/binexport CLASSPATH =. :/home/liaomeng/apache-jena-2.7.4/lib command export can view the various system variables and paths, found that the PATH in the system variables in the PATH more than the set PATH, added the CLASSPATH variable, if the setting is successful, you can view the output of a single variable: echo $ CLASSPATHecho $ PATH 2. add: export JENAROOT =/home/liaomeng/apache-jena-2.7.4export PATH = $ JENAROOT/bin: $ PATH at the end of the/etc/profile file # Add the jena PATH before the existing PATH variable, where the colon is the separator export CLASSPATH =.: $ JENAROOT/lib/jena-core-2.7.4.jar # Use *. jar seems to be difficult to use. I tried it many times. If multiple jar packages need to be added, separate source/etc/profile with a colon to make the modification take effect, you do not have to restart the system. Someone may say you can also go to/etc/profile. d/Add a sh file to the folder. The/etc/profile file appears to be automatically read from/etc/profile. d/I have not tried each script file in the folder. Note: The current directory "." In CLASSPATH cannot be lost. Dropping the current directory is also a common fatal error. When setting environment variables, pay special attention not to overwrite the original values. This is a common error. The more software you install, the more environment variables you add. To avoid confusion, we recommend that you add all statements at the end of the file and add them in the software installation order. 3. modify the hidden files in the main directory. the/bashrc modification method is the same as the modification of the/etc/profile file source. bashrc makes the modification take effect. I personally think it is important to understand the role of linux environment variables when running the program. Then, the format must be correct when adding the program. Generally, it will not be wrong.

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: 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.