Java FAQ _02 Basic use (013) _linux system How to manage environment variables

Source: Internet
Author: User

Click to enter _ more _java thousand ask

1. How Linux systems Manage environment variables

We all know that the configuration of the environment variables of Windows has been completely graphical, we can be in the properties of my Computer simple configuration, then for Linux, no graphical configuration of the operating system should be how to configure it? We specifically look at:

Environment variables in Linux include system-level and user-level, system-level environment variables are system variables to be read by every user logged into the system, and user-level environment variables are the environment variables that are loaded when the user uses the system. Here's how to configure it:

System-Level

By modifying the/etc/profile,/etc/environment file configuration

/etc/profile, the file is the first file that is used when a user logs on, the operating system customizes the user environment, and is applied to every user who logs on to the system. This file is typically called the/ETC/BASH.BASHRC file (System-level BASHRC file).

/etc/environment, which is the second file used by the operating system at logon, sets environment variables for environment files before reading your own profile.

User-level

~/.profile, each user can use this file to enter shell information that is specific to their own use.

~/.BASHRC, the file contains bash information dedicated to its own bash shell, which is read when it is logged in and every time a new shell is opened.

~/.pam_environment, user-level environment variable settings file.

Example:

We want to add the Java configuration to the system environment variables, as follows:

    1. Using Gedit to edit the/etc/proifle file (other editors can also), enter in the terminal:
      sudo gedit /etc/proifle

    2. Add the environment variables we want:
      export JAVA_HOME="/Library/Java"
      export PATH="$PATH:$JAVA_HOME/bin"
      export JRE_HOME="$JAVA_HOME/jre"
      export CLASSPATH=".:$JAVA_HOME/lib:$JRE_HOME/lib"

    3. Use the command to have the configuration take effect:
      source /etc/profile

Java FAQ _02 Basic use (013) _linux system How to manage environment variables

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.