linux /etc/profile,bashrc等文件的加载流程 以及 环境变量的设置
2017-04-05 22:51
453 查看
作者:spawpaw@hotmail.com 转载需注明出处
永久更新地址http://blog.csdn.net/qq_29753285/article/details/69367215
因为最近在debian上设置java环境变量,研究了一下profile等文件的加载流程
其实在ubuntu上也很相似,其他发行版的linux没有研究过。
环境变量一般在profile文件中设置,
如果只想本次登陆shell有效,直接在shell中输入
如果只想对当前用户生效,就在
如果想让设置对所有用户生效,就在
设置的方法很简单,只要在文件末尾按照如下语法添加
例如为所有用户添加java环境变量(注意,多个变量之间是用冒号分隔,而不是分号):
各个文件的加载顺序(其实系统启动时只加载了profile文件,然后profile文件递归加载了其余的文件):

永久更新地址http://blog.csdn.net/qq_29753285/article/details/69367215
因为最近在debian上设置java环境变量,研究了一下profile等文件的加载流程
其实在ubuntu上也很相似,其他发行版的linux没有研究过。
环境变量一般在profile文件中设置,
如果只想本次登陆shell有效,直接在shell中输入
export 变量名=变量值1[:变量值2[:...]]
如果只想对当前用户生效,就在
~/.profile中设置,
如果想让设置对所有用户生效,就在
etc/profile中设置。
设置的方法很简单,只要在文件末尾按照如下语法添加
export 变量名=变量值1[:变量值2[:...]]
例如为所有用户添加java环境变量(注意,多个变量之间是用冒号分隔,而不是分号):
#在/etc/profile 的末尾追加如下内容,JAVA_HOME改成你自己java的目录 export JAVA_HOME=/usr/share/jdk1.8 export PATH=$JAVA_HOME/bin:$PATH export CLASSPATH=.:$JAVA_HOME/lib/dt.jar:$JAVA_HOME/lib/tools.jar
各个文件的加载顺序(其实系统启动时只加载了profile文件,然后profile文件递归加载了其余的文件):

相关文章推荐
- Linux环境变量设置中配置文件分析(/etc/profile,~/.bashrc等)(转)
- linux环境变量设置 以及 source命令 Linux 之 /etc/profile、~/.bash_profile 等几个文件的执行过程 Linux 设置环境变量
- linux环境变量设置,/etc/profile,/etc/bashrc和.bash_profile的区别(作用域)
- Linux环境变量设置/etc/profile、/etc/bashrc、~/.profile、~/.bashrc区别
- linux的环境变量文件enviroment 、profile、bashrc和.bashrc以及.bash_profile
- Linux 启动时,先读取用户环境变量,即 /home/defonds/.bashrc 的设置。次读取所有用户环境变量,即 /etc/profile 中的配置。
- Linux环境变量设置/etc/profile、/etc/bashrc、~/.profile、~/.bashrc
- Linux 配置文件 启动文件rc.local、/etc/bash.bashrc、~/bashrc、/etc/profile、~/.profile加载顺序
- linux设置了 /etc/profile ~/.bashrc等配置文件不重启生效方法【开机读取的shll】
- Linux中环境变量文件profile、bashrc、bash_profile之间的区别和联系
- Linux环境配置文件 /etc/profile ~/.bash_profile ~/.bashrc /etc/bashrc的区别
- linux添加环境变量对/etc/profile文件进行修改过后导致命令用不了
- linux添加环境变量对/etc/profile文件进行修改过后导致命令用不了
- Linux中环境变量文件profile、bashrc、bash_profile之间的区别和联系
- linux的export命令和profile,.bashrc,bash.profile各种环境变量文件
- linux 环境变量设置 profile文件说明
- Linux中环境变量文件profile、bashrc、bash_profile之间的区别和联系
- Linux 每日一练习 !!!etc/profile里等设置环境变量导致图形无法登录
- 环境配置文件 ① /etc/profile、② ~/.bash_profile、③ ~/.bashrc、④ /etc/bashrc 作用与执行顺序,以及与login/nonlogin关系
- bash配置文件/etc/profile,/etc/bashrc,~/.bash_profile,~/.bashrc详解及修改PATH环境变量