[Recommended] Common methods to configure Linux environment variables!

WBOY
Release: 2024-02-19 13:06:14
forward
786 people have browsed it

[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!

Related labels:
source:mryunwei.com
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template