There are several files in Ubuntu that can set environment variables
/etc/profile: The first file that is used when the operating system customizes the user environment at logon, which sets the environment information for each user of the system, which is executed when the user logs on for the first time.
/etc/environment: The second file used by the operating system at logon, the system sets environment variables for environment files before reading your own profile
~/.profile: The third file that is used to log on is the. profile file, which each user can use to enter shell information that is specific to their own use, which is executed only once when the user logs on. By default, he sets some environment variables, Executes the user's. bashrc file.
/ETC/BASHRC: Executes this file for each user running the bash shell. When the bash shell is opened, the file is read.
~/.BASHRC: This file contains bash information dedicated to your bash shell, which is read when you log in and every time you open a new shell.
There are three ways to set environment variables generally:
First, temporary settings
Export Path=/home/yan/share/usr/local/arm/3.4.1/bin: $PATH
Second, the current user's global settings
Open ~/.BASHRC, add line:
Export Path=/home/yan/share/usr/local/arm/3.4.1/bin: $PATH
Make effective
source. BASHRC
Third, global settings for all users
$ vim/etc/profile
Add in:
Export Path=/home/yan/share/usr/local/arm/3.4.1/bin: $PATH
Make effective
Source Profile
Test echo $PATH
There are two ways to set the environment variable PATH. The first applies to setting the path for a single user, and the second is to set the path globally.
1. In the user's home directory, there is a. bashrc file, where you can include the PATH in the following settings:
Open with GEDIT/ROOT/.BASHRC.
Export path= "$PATH:/your path1/:/your path2/..."
Note: Separate each path with a ":".
2. Increase in/etc/profile.
Path= "$PATH:/home/zhengb66/bin"
Export PATH
If you want to make immediate effect, use the source command
source. BASHRC
Complete.
Setting environment variables under Ubuntu