CentOS中的环境变量配置文件

1.修改/etc/profile文件,将影响全局,所有用户。/etc/profile在系统启动后第一个用户登录时运行。在/etc/profile文件中添加

export PATH=/someapplication/bin:$PATH

要使修改生效,可以重启系统,或者执行

source /etc/profile
echo $PATH

2.修改/etc/environment,将影响全局。/etc/environment文件与/etc/profile文件的区别是:/etc/environment设置的是系统的环境,而/etc/profile设置的是所有用户的环境,即/etc/environment与用户无关,在系统启动时运行。在/etc/environment文件中添加

PATH=/someapplication/bin:$PATH

CentOS和大多Linux系统使用$访问环境变量,环境变量PATH中使用冒号:分隔。而Windows中使用两个%访问环境变量,PATH使用分号;分隔,例如:

set PATH=E:\someapplication\bin;%PATH%

3.修改~/.bash_profile(首选),将影响当前用户。在~/.bash_profile文件中添加

export PATH=/someapplication/bin:$PATH

5.修改~/.bashrc,影响当前用户使用的bash shell。

扫描二维码关注公众号,回复: 1967864 查看本文章

6.在终端中执行以下命令,只影响当前终端。

export PATH=/someapplication/bin:$PATH

猜你喜欢

转载自www.linuxidc.com/Linux/2017-01/139118.htm