1. Set the environment variable directive:
Export
For example: Export m2_home= "/opt/maven" This instruction set the M2_home point to a path
Echo View
echo $M 2_home If m2_home is defined, its value is displayed
Modify
Modify the environment variable for path path and append a path
Export path= $PATH:/home/kvmimg This is to append a string directly as a supplemental path, which is equivalent to stitching directly on the original path ":/home/kvmimg"
It can also be spliced by environment variables:
Export path= $PATH: $M 2_home
2. Effective Range
The same as Windows CMD window, in the CMD window to perform any environment variable settings, close the window after the new window, it is invalid, if set to the system to set environment variables
Linux is the same, there are several places in Linux can set environment variables
1,/etc/profile: At logon, the operating system to customize the user environment to use the first file, this file for each user of the system to set the environment information, when the user first logon, the file was executed.
2./etc/environment: The second file that the operating system uses at login, the system sets the environment variable of environment file before reading your own profile.
3, ~/.BASHRC: This file contains bash information dedicated to your bash shell, which is read when you log in and each time you open a new shell. ~ Represents the user directory, such as:/root or/home/lawmansoft
4./etc/rc.local: Scripts that are executed automatically
3. View all Environment variables
Env can also append grep to filter, for example: Env |grep java_home will show: java_home=usr/lib/jvm/jdk1.7.0_01
Setting up the system for English environment
Export Lang=uc_en