There are three ways to set environment variables in Ubuntu: one for the current terminal, the other for the current user, and the other for all users. Next let's take a look at the specific settings. Ubuntu
I. used on the current terminal:
Enter:
Copy codeThe code is as follows:
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:
Copy codeThe code is as follows:
Vi ~ /. Bashrc
Join:
Copy codeThe code is as follows:
Export PATH = <Path you want to add> : $ PATH
If you want to add multiple paths, as long:
Copy codeThe code is as follows:
Export PATH = <Path 1 you want to add> : <Path 2 you want to add> : ......: $ PATH
Each path must be separated by a colon.
In this way, each login will take effect.
3. for all users:
Copy codeThe code is as follows:
Sudo vi/etc/profile
Join:
Copy codeThe code is as follows:
Export PATH = <Path you want to add> : $ PATH
You can.