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:
~/.profile
~/.bash_profile or ~./bash_login
~/.bashrc
the above-mentioned documents Ubuntu 10.0 Previous versions are not recommended.
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 in the Ubuntu 10.0 version.
If you want to take effect immediately, execute sudo ldconfig
Adding environment variables
If you want to add a path to the $PATH , you can do this as follows (modify /etc/profile):
$ sudo vi/etc/profile
Add in :
Export path= "$PATH:/my_new_path"
You can add a specified number of paths yourself, usually one row per path, press ESC to exit the edit, enter a colon plus wq to save the exit.
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:
$source/etc/profile
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 way, note that/etc/environment does not need to use export to set environment variables, other profiles file required.
For more detailed instructions, refer to here.
Ubuntu Linux system contains two types of environment variables