Home >Computer Tutorials >Computer Knowledge >[Recommended] Common methods to configure Linux environment variables!
In Linux systems, environment variables are an important mechanism for storing information about the system's running environment. When we customize the installation of software, we usually need to configure environment variables. The following are several common methods for configuring Linux environment variables. I hope they will be helpful to you.
1. export PATH
Use the export command to directly modify the value of PATH and configure the method for MySQL to enter environment variables:
Export PATH=/home/uusama/mysql/bin:PATH# Or put PATH in front export
PATH=PATH:/home/uusama/mysql/bin
Precautions:
Effective time: Effective immediately
Validity period: Valid for the current terminal, invalid after the window is closed
Effective scope: only valid for the current user
Don’t forget to add the original configuration, that is, the $PATH part, to the configured environment variables to avoid overwriting the original configuration
2.vim~/.bashrc
Configure by modifying the ~/.bashrc file in the user directory:
vim~/.bashrc# Add export PATH=$PATH to the last line:/home/uusama/mysql/bin
Precautions:
Effective time: It will take effect when opening a new terminal with the same user, or manually source ~/.bashrc to take effect
Validity period: Valid forever
Effective scope: only valid for the current user
If there are subsequent environment variable loading files that overwrite the PATH definition, it may not take effect
3. vim ~/.bash_profile
Similar to modifying the ~/.bashrc file, you also need to add a new path at the end of the file:
vim ~/.bash_profile# Add export PATH=$PATH in the last line:/home/uusama/mysql/bin
Precautions:
Effective time: It will take effect when opening a new terminal with the same user, or manually source ~/.bash_profile
Validity period: Valid forever
Effective scope: only valid for the current user
The above is the detailed content of [Recommended] Common methods to configure Linux environment variables!. For more information, please follow other related articles on the PHP Chinese website!