Linux environment variable Configuration

Source: Internet
Author: User

Linux environment variables are related to several files:

    • /etc/profile--This file sets the environment information for each user of the system, and the file is executed the first time the user logs on. and collects shell settings from the configuration file of the/ETC/PROFILE.D directory;

    • /etc/environment--the second file that the operating system uses when logging on, the system sets environment variables for environment files before reading your own profile;

    • /etc/bashrc--executes this file for each user running the bash shell. When the bash shell is opened, the file is read;

    • ~/.profile--Each user can use this file to enter shell information dedicated to their own use, and when the user logs in, the file is only executed once! By default, it sets some environment variables to execute the user's. bashrc file;

    • ~/.bashrc--The file contains bash information dedicated to your bash shell, which is read when you log in and every time you open a new shell;

Example: Configure the JDK. Select the appropriate files as needed and add them at the end of the file:

Export java_home=/usr/lib/jvm/jdk1.7.0_55

Export JRE_HOME=${JAVA_HOME}/JRE

Export Classpath=.:${java_home}/lib:${jre_home}/lib

Export Path=${java_home}/bin: $PATH

You can also enter the above command directly on the terminal command line, but only for the current shell

Note the following points: (Excerpt from: http://blog.sina.com.cn/s/blog_5016ee390102ehsn.html)

Example 1. Export Java_home= "Your Path"

Example 2. Exprot path= $PATH: Yourpath

1. If the system already has a variable, such as path, then use the connection method in Example 2. Use $path to invoke the existing settings, a colon after adding their own path, if the original $path is not connected, then path is overwritten, the consequences are very serious.

2. If it is your own new set of variables, routinely 1.

3. The equal sign between the variable name and the variable value = no space on either side, or an error!

4. The value of the variable on the right side of the equal sign can be double-quoted (example 1) or not (example 2)

After the update is complete, perform the source. BASHRC or source. Profile Update system settings. Call echo $JAVA _home or echo $PATH to see how the update works!

Linux environment variable Configuration

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.