In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-01-19 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Development >
Share
Shulou(Shulou.com)06/01 Report--
This article will explain in detail how to configure environment variables in the Linux system. The editor thinks it is very practical, so I share it for you as a reference. I hope you can get something after reading this article.
Introduction to environment variables: an environment variable is an object with a specific name in the operating system that contains information that will be used by one or more applications.
A storage unit to which a variable can be assigned at will
Environment
Such as jvm, these are small software, they are in the operating system this big software.
The role of environmental variables
The function of a variable in any program is "assigned / taken"! This global variable operating system can be used, and the small software in it can also be used!
The temporary environment variable modifies the PATH with the command line, which is only useful for the current shell. If you close the terminal, it will become invalid.
1. Add path to PATH add path can directly assign value to PATH
Export PATH=$PATH: newly added path or PATH=$PATH: newly added path (shutdown terminal fails) $PATH is the current environment variable, in the format of path 1: path 2: path 3, append: newly added path, and then assign the new path set to PATH itself, which is equivalent to overwriting the original PATH variable. The export command is an export variable, which is equivalent to updating PATH
two。 Delete a path in PATH Delete a path in PATH also use the above method to reassign PATH, for example, the current PATH is
Echo $PATH path 1: path 2: path 3: path 4 to delete path 4, just need path 1: path 2: path 3 on copy, and then assign a value to PATH
Export PATH= path 1: path 2: path 3 (shutdown terminal failure) the permanent environment variable adds a statement to the system file (such as .bashrc under HOME), and then source or restart, permanently.
Plain text file modification PATH requires source for each login, which is often used in software installation and cross-compilation
The modification in the system file is equivalent to automatically source each time you log in to the system. Refer to adding environment variables to the system-level or user-level files.
(it is recommended to use root account to modify system files and set up root account)
Log in to root and add a new path to PATH in the .bashrc file in the $HOME directory (root)
Export PATH=$PATH: a more direct way to add new paths: specify all the paths of PATH in .bashrc. Note that you need to echo $PATH first, and then the path that comes with the copy system.
Export PATH= path 1: path 2: path n so add and delete paths can be directly rewritten .bashrc.
To take effect immediately, you only need to source the .bashrc file, and then you don't need to source.
The changes in source .bashrc.bashrc are valid for each login of the current account.
To restore the system default PATH, delete the modification statement in .bashrc.
You can also modify the following system files:
1./etc/profile adds PATH=$PATH:/etc/apache/bin at the appropriate location (note: = that there can be no spaces on both sides of the equal sign). This method is best, unless you manually force to change the value of PATH, it will not be changed.
2.~/.bash_profile modifies the PATH line to add / etc/apache/bin. This method works for users.
Note: if you want to change PATH, you must log in again to take effect, the following method can simplify the work: if you modify / etc/profile, then execute source profile (source / etc/profile) or execute the point command. / profile,PATH will take effect immediately. The principle of this method is to execute the / etc/profile shell script again, note that it is not possible to use sh / etc/profile, because the sh is executed in the child shell process, even if the PATH changes will not be reflected in the current environment, but the source is executed in the current shell process, so we can see the PATH change. In this way, you will learn how to modify the path of the environment variable PATH in the Linux system.
This is the end of this article on "how to configure environment variables in Linux system". I hope the above content can be of some help to you, so that you can learn more knowledge. if you think the article is good, please share it for more people to see.
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.
Continue with the installation of the previous hadoop.First, install zookooper1. Decompress zookoope
"Every 5-10 years, there's a rare product, a really special, very unusual product that's the most un
© 2024 shulou.com SLNews company. All rights reserved.