当前位置: > Linux教程 > linux基础 >

Linux bash的用户环境设定文件(RH linux,Centos)

时间:2014-12-15 22:53来源:linux.it.net.cn 作者:IT
1 当以bash登陆Linux环境时,
  .各种用户环境设定文件的读取顺序如下
1,读取 /etc/profile   
2, 按顺序搜索~/.bash_profile, ~/.bash_login, ~/.profile这三个文件,最先找到的文 件被读取,之后的文件忽略
 .如果存在~/.bash_profile 则有以下动作
1,通过~/.bash_profile,读取~/.bashrc
2,通过~/.bashrc,读取/etc/bashrc
 
 .Centos64的默认 ~/.bash_profile内容是
[vagrant@localhost ~]$ cat  .bash_profile
# .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

 
 .Centos64的默认~/.bashr内容是
[vagrant@localhost ~]$ cat .bashrc
# .bashrc

# Source global definitions

if [ -f /etc/bashrc ]; then

   . /etc/bashrc

fi

# User specific aliases and functions

2 其他的bash启动方式(非用户登陆方式)
1, 读取~/.bashrc
2, 通过读取~/.bashrc,读取到~/etc/bashrc

3 各种配置文件的一般使用方法
 
 /etc/profile:设定对所有用户都起作用的配置,只需要配置一次就永远起作用。
~/.bash_profile:针对不同用户设定不同的配置。只需要配置一次就永远起作用
~/.bashrc:    比如alias等每次需要在shell启动的时候配置的内容。


(责任编辑:IT)
------分隔线----------------------------
栏目列表
推荐内容