how-to-set-environment-path-variable
来源:互联网 发布:labview软件架构 编辑:程序博客网 时间:2024/05/17 02:01
There is a time when every Linux Administrator gets stuck at a point of his career when he/she has to set a custom path or any other environment variable permanently in the Linux machine.
Suppose you have added a new path to the PATH variable using the shell but you might observe that every time you switch terminal the PATH variable does not works.
Solution
To make this issue to be resolved permanently you need to add the variable inside .bashrc or.bash_profile file inside the home folder of the user.
For example, you want to add a PATH variable for root user so you need to add the path inside~/.bashrc or ~/.bash_profile
Now the confusion comes which file should we place the variable or inside both the files?
Every time you login to a Linux (Red Hat) machine .bash_profile file is executed
but
In case you are already logged in and you open a new terminal then .bashrc file is executed
So, basically you can put the environment variable inside any of the two files. As per me I would advice you to put the same inside .bash_profile.
Have a look at .bash_profile file
Suppose you have added a new path to the PATH variable using the shell but you might observe that every time you switch terminal the PATH variable does not works.
Solution
To make this issue to be resolved permanently you need to add the variable inside .bashrc or.bash_profile file inside the home folder of the user.
For example, you want to add a PATH variable for root user so you need to add the path inside~/.bashrc or ~/.bash_profile
Now the confusion comes which file should we place the variable or inside both the files?
Difference between .bashrc and .bash_profile
but
In case you are already logged in and you open a new terminal then .bashrc file is executed
So, basically you can put the environment variable inside any of the two files. As per me I would advice you to put the same inside .bash_profile.
WHY?
Have a look at .bash_profile file
# less ~/.bash_profile
# Get the aliases and functions
if [ -f ~/.bashrc ]; then
. ~/.bashrc
fi
# User specific environment and startup programs
PATH=$PATH:$HOME/bin
export PATH
export PATH=$PATH:/usr/local/samba/bin
You can see in the highlighted part in blue in the above part, every time .bash_profile is executed it also runs .bashrc along with it. As you can see I have added an extra PATH variable for my samba so that I do not need to set it every time I log in.
---------------------------------
永久性设置oracle环境变量
Vim /home/oracle/.bash_profile
0 0
- how-to-set-environment-path-variable
- How to Set $JAVA_HOME environment variable on Mac OS X
- how to java --->environment variable
- Exception: Environment variable "SYSTEMROOT" required to be set to valid path
- Oracle:environment variable "PATH"
- How to set up CI environment
- How to check environment variable in robot framework?
- How do I set or change the PATH system variable?
- DISPLAY environment variable not set!
- How to variable path of log output via log4net
- 设置Path变量 - Batch Script To Manage Windows PATH Environment Variable
- please update to a more recent version, or set ANDROID_DAILY_OVERRIDE environment variable to "a8faa
- Windows下安装PostgreSQL 9.0.4:unable to write inside temp environment variable path
- 【终结方案】 Windows下安装PostgreSQL 9.0.4:unable to write inside temp environment variable path
- Oracle的Environment variable:"path" 失败问题
- Oracle 客户端安装 Environment variable: "PATH" -
- Environment variable ORACLE_UNQNAME not defined. Please set ORACLE_UNQNAME to database unique name
- Environment variable ORACLE_UNQNAME not defined. Please set ORACLE_UNQNAME to database unique name.
- Save and Load from XML
- Eclipse突然不能启动
- DB2备份
- 信号量的分类(参考别人,自己总结)
- js开发手册
- how-to-set-environment-path-variable
- js 中 split 和replace的候用
- Maven3入门
- c:forEach 遍历集合中的元素,判断是否是最后一个元素
- 使用scala容器
- 为什么流量过万转化率却很低?
- weka[7] - Adaboost
- 佳能相机照片误删怎么恢复,误删的数码相机照片怎么恢复
- js正则表达式