Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

How to configure the environment variables of CentOS linux

2025-01-19 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Development >

Share

Shulou(Shulou.com)06/02 Report--

This article mainly explains "how to configure the environment variables of CentOS linux". 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 configure the environment variables of CentOS linux.

CentOS's environment variable profile system is a hierarchical system, which is similar to other multi-user application system configuration files, including global, user and shell, and different levels are sometimes similar to inheritance relationships. Take the PATH variable as an example.

1. Modify the / etc/profile file, will affect the global, all users. / etc/profile runs when the first user logs in after the system starts. Add to the / etc/profile file

Export PATH=/someapplication/bin:$PATH

For the changes to take effect, you can restart the system or execute

Source / etc/profile

Echo $PATH

two。 Modifying / etc/environment will affect the overall situation. The difference between the / etc/environment file and the / etc/profile file is that / etc/environment sets the environment of the system, while / etc/profile sets the environment of all users, that is, / etc/environment is independent of the user and runs at system startup. Add to the / etc/environment file

PATH=/someapplication/bin:$PATH

CentOS and most Linux systems use $to access environment variables, and environment variables PATH are separated by colons:. Windows uses two% access environment variables, and PATH uses semicolons; delimited, for example:

Set PATH=E:\ someapplication\ bin;%PATH%

3. Modify ~ / .bash_profile (preferred), which will affect the current user. Add to the ~ / .bash_profile file

Export PATH=/someapplication/bin:$PATH

4. Modify / etc/bashrc (/ etc/bash.bashrc in Ubuntu and Debian) to affect the bash shell used by all users. / etc/bashrc, as its name implies, is created to initialize bash shell and runs when bash shell is turned on. There are different categories of bash shell: login to shell and non-login shell, login to shell requires entering a user password, such as ssh login or su-command rights will start login shell mode. Non-login shell will not execute any profiel files; interactive shell and non-interactive shell, providing command prompts waiting for user input commands is interactive shell mode, running script files directly is non-interactive shell mode, generally non-interactive shell mode does not execute any bashrc files. Based on the above, choose whether or not to modify / etc/bashrc.

5. Modify ~ / .bashrc to affect the bash shell used by the current user.

6. Execute the following command in the terminal, affecting only the current terminal.

Export PATH=/someapplication/bin:$PATH

At this point, I believe you have a deeper understanding of "how to configure the environment variables of CentOS linux". 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!

Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.

Views: 0

*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

Share To

Development

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report