[Linux] sets Environment Variables
Setting environment variables in Windows is very easy. For example, right-click my computer> advanced system Settings> environment variables, select Path, and click "edit" to enter the content you want to add. You can add some command line commands that you want to run directly. For example, in java, the bin directory under jdk should be put up.
However, it is not that simple in Linux.
Take Ubuntu as an example. There are two ways to set environment variables:
Press Ctrl + Alt + T to open the terminal and enter:
sudo gedit /etc/environment
Enter the password, open the configuration file of the system variable, and modify the content.
Add system environment variables directly at the end
: The path you want to set.
Use the colon (:) to separate folders.
Save and exit.
source /etc/environment
Make it take effect.
This command can also restore errors of inherent commands such as sudo. When you enter sudo, the prompt "xx is not in the path environment variable, so this command cannot be found" appears, if your/ext/environment has not been modified, you can use this command to fix it.
However, this is generally not recommended. If an error occurs, the sudo command of ubuntu cannot be executed.
Generally, the user environment variables are set:
gedit ~/.bashrc
Open the user environment variable configuration file, which can be opened without using the sudo command, because it is a user environment variable,
To the end, add the following sentence:
Export PATH = xx: $ PATH, where xx is the PATH you set. $ PATH is indispensable. If it is not formatted, sudo, apt-get, and other inherent commands cannot be executed.
For example, configure the adb command of Android to the user's environment variable.
Save and exit. Enter the following information on the terminal:
source ~/.bashrc
.