Get the App
SLTechnology News&Howtos  ›  Servers  › 

How to add environment variables to CentOS

Shulou Source: shulou.com Published: 2022-06-01 13:20:13 11月04日 Update

This article mainly explains "how to add environment variables to CentOS". Interested friends may wish to take a look. The method introduced in this paper is simple, fast and practical. Let's let the editor take you to learn how to add environment variables to CentOS.

After installing MATLAB on a Linux CentOS system, you need to add the matlab command to the system command for ease of use. If you execute the "matlab" command before adding it to the environment variable, you will be prompted for an error that does not exist in the command, as shown below:

Let me explain in detail how to add MATLAB to the environment variable under linux (MATLAB is installed in the / usr/local/MATLAB/R2013a/bin directory).

Method 1 (effective temporarily)

Running the command export PATH=$PATH:/usr/local/MATLAB/R2013a/bin directly, using this method, will only take effect for the current reply, that is, every time you log out or log out of the system, the PATH setting will become invalid, only temporarily.

Method 2 (effective only for currently logged-in users, permanent)

Execute vim ~ / .bash_profile to modify the PATH line in the file, add / usr/local/MATLAB/R2013a/bin to the PATH=$PATH:$HOME/bin line (separated by colons), save the file and exit, execute source ~ / .bash_profile to make it effective, this method only works for the current login users.

If you see the following figure, you can see that the environment variable has been added successfully:

Method 3 (effective for all system users, permanent)

Modify the / etc/profile file by adding the following two lines of code at the end of the file

PATH=$PATH:/usr/local/MATLAB/R2013a/binexport PATH

Finally, execute the command source / etc/profile or the point command. / profile to make the changes take effect.

At this point, I believe you have a deeper understanding of "how to add environment variables to CentOS". You might as well do it in practice. Here is the website, more related content can enter the relevant channels to inquire, follow us, continue to learn!

Tags: Commands methods variables environment files systems users one line content permanent learning login practical deeper successful that is code easy to use interest Apple Docker Huawei Linux macOS MariaDB Microsoft MySQL NVidia OPPO Reno macOS Shulou Technology Xiaomi Shulou Tech Info NVidia