Home >Operation and Maintenance >Linux Operation and Maintenance >How to modify linux environment variables

How to modify linux environment variables

WBOY
WBOYOriginal
2021-12-28 17:36:0519496browse

Method: 1. Execute the "export PATH=$PATH:/usr/local/MATLAB/R2013b/bin" command to temporarily modify it; 2. Execute the "gedit /etc/profile" command and log out of linux. Linux environment variables can be permanently modified.

How to modify linux environment variables

#The operating environment of this tutorial: linux7.3 system, Dell G3 computer.

How to modify the linux environment variables

Temporarily modify the environment variables

Open the Linux terminal In the command window, enter the following command:

export PATH=$PATH:/usr/local/MATLAB/R2013b/bin

In order to verify whether the modification is successful, you can continue to enter the command eport to view. In the picture below, you can see that the matlab environment variable has been successfully added.

How to modify linux environment variables

How to modify linux environment variables

After the above modification, if you exit the terminal and reopen it to view the environment variables again, you will find that the environment variables added above have disappeared. That is to say, this only temporarily modifies the environment variables.

How to modify linux environment variables

Permanent modification of environment variables

If you want the environment variables to take effect permanently, you can modify either of the following two files:

1 /etc/profile

2 .bash_profile

Among them, /etc/profile is a global environment variable that takes effect for all users, while .bash_profile only applies to the current user Activate.

How to modify linux environment variables

‍Enter the command:

gedit /etc/profile Open the profile file and add the following statements. After the input is completed, save and exit gedit

How to modify linux environment variables

How to modify linux environment variables

#After the above operation is completed, you need to log out of Linux to make the environment variable settings just take effect.

Related recommendations: "Linux Video Tutorial"

The above is the detailed content of How to modify linux environment variables. For more information, please follow other related articles on the PHP Chinese website!

Statement:
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