Set environment variables in Ubuntu
There are three methods to set environment variables in Ubuntu: one for the current terminal, the other for the current user, and the other for all users.:
I. Used on the current terminal:
Enter:Export Path = $ path: <path you want to add>
However, the above method only applies to the current terminal. Once the current terminal is closed or in another terminal, it is invalid.
Ii. Used for the current user:
There is a. bashrc hidden file in the user's main directory. You can add the path settings in this file as follows:
VI ~ /. Bashrc
Join:
Export Path = <path you want to add>: $ path
If you want to add multiple paths, as long:
Export Path = <the path you want to add 1 >:< the path you want to add 2 >:......: $ path
Each path must be separated by a colon.
In this way, each login will take effect.
3. for all users:
Sudo VI/etc/profile
Join:
Export Path = <path you want to add>: $ path
You can.
Terminal input:Echo $ PATH allows you to view environment variables
Note: After the environment variable is modified, except for the first method, the second method takes effect immediately ~ /. Bashrc or log out and log on again!
Done!