In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-02-24 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Servers >
Share
Shulou(Shulou.com)06/01 Report--
This article to share with you is about linux environment variable mismatch solution, Xiaobian think quite practical, so share to everyone to learn, I hope you can read this article after some harvest, not much to say, follow Xiaobian to see it.
Friends in linux configuration environment variables when typing the wrong command, resulting in the newly added environment variables overwrite the original environment variables, the direct result is that most of the commands under Linux can not be used, this can scare my friend, he has never encountered such a problem, after my help and explanation, he found that this problem is not terrible, now has been solved, write a blog post, hope to make the same mistakes people quickly solve this problem.
In Linux, divided by the life cycle of variables, Linux variables can be divided into two categories, and their modification methods are as follows:
(1) Permanent: The configuration file needs to be modified, and the variable takes effect permanently.
Common profiles include:
(1-1)/etc/profile: effective for all users; this file sets the environment information for each user of the system, when the user is
This file is executed on a login; shell settings are collected from configuration files in the/etc/profile.d directory
For example: edit/etc/profile file, add CLASSPATH variable
# vi /etc/profile
Add a line:
export CLASSPATH=./ JAVA_HOME/lib;$JAVA_HOME/jre/lib
After modification, you need to log in again to take effect, or you can execute the command source /etc/profile to take effect.
(1-2)/etc/bashrc: Effective for all users; execute this file for each user running bash shell. When bash
When the shell is opened, the file is read.
The editing method is as above and will not be repeated.
(1-3)~/.bash_profile: Valid only for the current user; each user can use this file to enter inputs specific to themselves
shell information used, which is executed only once when the user logs in
For example: edit.bash_profile under guok user directory (/home/guok)
$ vi /home/guok/.bash_profile
Add the following:
export CLASSPATH=./ JAVA_HOME/lib;$JAVA_HOME/jre/lib
After modification, you need to log in again to take effect, or you can execute the command source /etc/profile to take effect.
(1-4)~/.bashrc: valid only for the current user; this file contains bash information specific to your bash shell, when
This file is read at login and every time a new shell is opened.
The editing method is the same as above, and will not be repeated again.
In addition, variables (local) set in ~/.bashrc can only inherit variables in/etc/profile, they are "parent-child"
Relationship.
Summary, modify the above file, add the variables you need, when starting a shell (terminal), you
The variables defined will take effect.
(2) Temporary: Use the export command declaration, variables are only available under the current shell(BASH) or its subshell (BASH)
Effective, invalid after closing the shell, and then open a new shell without this variable, if you need to use it, you need to redefine.
Definition method: directly use [export variable name = variable value] under the command line of shell to define variables
Problem phenomena:
Solution:
Direct workaround: Enter export PATH=/usr/bin:/usr/sbin:/bin:/sbin:/usr/X11R6/bin on the command line
After this sentence is executed, it only takes effect temporarily. You need to save this sentence to/etc/profile to take effect permanently.
#source /etc/profile
At this point all environment variables are restored and can be viewed via echo $PATH.
The above is the solution to the mismatch of environmental variables under Linux. Xiaobian believes that some knowledge points may be seen or used in our daily work. I hope you can learn more from this article. For more details, please 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.
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.