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 modify environment variables in Linux system

2025-02-23 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Development >

Share

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

This article shows you how to modify environment variables in Linux system, which is concise and easy to understand, which will definitely brighten your eyes. I hope you can get something through the detailed introduction of this article.

1. Add a variable to the / etc/profile file [effective for all users (permanent)]

Add a variable to the file / etc/profile file with VI, which will be valid for all users under Linux and will be "permanent".

For example: edit / etc/profile file, add CLASSPATH variable

\ # vi / etc/profile export CLASSPATH=./JAVA_HOME/lib;$JAVA_HOME/jre/lib Note: if you want to take effect immediately after modifying the file, you have to run # source / etc/profile, otherwise it will only take effect the next time you reenter this user.

2. Add a variable to the. bash_profile file under the user directory [effective for a single user (permanent)]

Use VI to add variables to the. bash_profile file in the user directory, and the changes are only valid for the current user and are "permanent".

For example: edit the. bash_profile under the guok user directory (/ home/guok)

$vi / home/guok/.bash.profile adds the following:

Export CLASSPATH=./JAVA_HOME/lib;$JAVA_HOME/jre/lib note: if you want to change the file to take effect immediately, you have to run $source / home/guok/.bash_profile, otherwise it will only take effect the next time you reenter this user.

3. Run the export command directly to define variables [valid only for the current shell (BASH) (temporary)]

Use [export variable name = variable value] directly under the command line of shell

Define a variable, which is valid only under the current shell (BASH) or its child shell (BASH). When shell is closed, the variable is invalid, and there is no such variable when you open the new shell. You need to redefine it if you need to use it.

The above is how the Linux system modifies the environment variables. have you learned the knowledge or skills? If you want to learn more skills or enrich your knowledge reserve, you are welcome to follow the industry information channel.

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