Ubuntu Linux systems contain two types of environment variables: System environment variables and user environment variables. The system environment variable is valid for all system users, and the user environment variable is only valid for the current user.
modifying user environment variables
User environment variables are typically stored in the following file:
The above files are not recommended for use in previous versions of Ubuntu 10.0.
System Environment variables
The system environment variables are generally stored in the following file:
/etc/environment
/etc/profile
/etc/bash.bashrc
/etc/profile and/ETC/BASH.BASHRC are not recommended for use in Ubuntu version 10.0.
Adding environment variables
If you want to add a path to $path, you can do the following (modify/etc/profile):
Add in:
123456 |
JAVA_HOME= /usr/jdk1 .6.0_25 export JAVA_HOME PATH=$PATH:$JAVA_HOME /bin export PATH CLASSPATH=.:$JAVA_HOME /lib export CLASSPATH |
You can add the specified number of paths yourself, separated by colons. When the environment variable is changed, it takes effect the next time the user logs on, and if you want to take effect immediately, you can execute the following statement:
It is important to note that it is best not to put the current path "./" in path, which may be subject to unexpected attacks.
Other files are modified in a similar manner, and it is important to note that/etc/environment does not need to use export to set environment variables that other profile files require.
For more detailed instructions, refer to here.
Of course, if you want to use the text Editing tool to modify environment variables, you can use the root permission to log in, directly with a text editor open modify Save
can also be normal user permissions to copy files to the desktop and other changes with the root permission to cover back
1234567891011121314151617181920212223242526272829303132333435 |
# /etc/profile: system-wide .profile file for the Bourne shell (sh(1))
# and Bourne compatible shells (bash(1), ksh(1), ash(1), ...).
if [ -d
/etc/profile
.d ];
then
for i
in /etc/profile
.d/*.sh;
do
if [ -r $i ];
then
. $i
fi
done
JAVA_HOME=
/usr/hadoop/jdk1
.6.0_25
export JAVA_HOME
PATH=$PATH:$JAVA_HOME
/bin
export PATH
CLASSPATH=.:$JAVA_HOME
/lib
export CLASSPATH
unset i
fi
if [
"$PS1" ];
then
if [
"$BASH" ];
then
# The file bash.bashrc already sets the default PS1.
# PS1=‘\h:\w\$ ‘
if [ -f
/etc/bash
.bashrc ];
then
.
/etc/bash
.bashrc
fi
else
if [
"`id -u`" -
eq 0 ];
then
PS1=
‘# ‘
else
PS1=
‘$ ‘
fi
fi
fi
|
http://snowfigure.diandian.com/post/2012-09-23/40038540721
Ubuntu sets environment variables and takes effect immediately