Set environment variables in three ways in Linux and in three ways in linux
1. In windows, environment variables must be configured for many software installations, such as jdk installation. If environment variables are not configured, run the javac command in a directory other than software installation, the file cannot be found. A similar error is reported.
2. What are environment variables? Simply put, it is to specify a directory. when running the software, the relevant program will find the relevant files according to the directory. The most practical function for setting variables is that you do not need to copy some dll files to the system directory. The path system variable is a series of paths for the system to search for dll files.
In linux, If you download and install an application, it is very likely that the prompt "command not found" appears when you type its name. It is too cumbersome to find the executable file in the installation directory every time. This involves setting the environment variable path, and the Path setting is also an integral part of customized environment variables in linux.
Three methods for setting environment variables in linux:
To add a PATH to $ PATH, perform the following operations:
1. Set in the console. This method is not supported, because it only works for the current shell and is invalid for another shell:
$ PATH = "$ PATH":/NEW_PATH (disabling shell Path will restore to the original path)
2. Modify the/etc/profile file. If your computer is used only for development and usage, this method is used because all users' shells have the right to use this environment variable, security issues may occur to the system. This is for all users, all shells
Add: export PATH = "$ PATH:/NEW_PATH" at the bottom of/etc/profile"
3. Modify the bashrc file. This method is more secure. It can control the permissions to use these environment variables to the user level. This method is for a specific user, if you want to grant a user permission to use these environment variables, you only need to modify. you can use the bashrc file.
Add the following content:
Export PATH = "$ PATH:/NEW_PATH"