|
linux环境变量修改 |
|
|
redhat和ubuntu中修改环境变量
有些命令的路径没有在PATH环境变量中,可以用echo$PATH命令查询得知,添加路径到PATH环境变量的方法如下:
(如添加/sbin到PATH环境变量中)
(1)如果只想在本次开机过程中临时性的添加修改,下次开机就无效的话,可以:
输入exportPATH=$PATH:/sbin
(2)如果只给当前用户永久添加,则:
在~/.bash_profile中的靠近末尾有类似这样的一行PATH=$PATH:$HOME/bin后添加:/sbin,就变成PATH=$PATH:$HOME/bin:/sbin
文件修改并保持完以后,运行source~/.bash_profile命令即可使修改操作立即生效
(3)如果给系统中所有的用户都永久添加,则:
在/etc/profile文件中添加pathmunge:/sbin
如:/etc/profile文件打开后有如下代码
????.....................
????16#Pathmanipulation????17if[`id-u`=0];then????18????????pathmunge/sbin????19????????pathmunge/usr/sbin????20????????pathmunge/usr/local/sbin????21fi
????........................
你将之改成:
?????........................
??16#Pathmanipulation????17if[`id-u`=0];then????18????????pathmunge/sbin????19????????pathmunge/usr/sbin????20????????pathmunge/usr/local/sbin????21????????pathmunge/usr/local/arm/bin????22fi
????.......................
表示将/usr/local/arm/bin添加进环境变量
文件修改并保持完以后,运行sourceetc/profile命令即可使修改操作立即生效
在redhat系统中有两种设置环境变量PATH的方法。第一种适用于为单一用户设置PATH,第二种是为全局设置PATH。第一种方法:在用户主目录下有一个.bashrc文件,可以在此文件中加入PATH的设置如下:exportPATH=”$PATH:/yourpath1/:/yourpath2/…..”注意:每一个path之间要用“:“分隔。注销重启X就可以了。第二种方法:在/etc/profile中增加。PATH="$PATH:/home/zhengb66/bin"exportPATH
在ubuntu下修改PATH值,可以再/etc/environment中修改
|
|
|
|
|
|
|
|
|
|
|