Bash Shell配置文件解析(based on ubuntu 10.04 LTS)

文件 /etc/profile:

root@keen-home:/etc/profile.d# cat /etc/profile
# /etc/profile: system-wide .profile file for the Bourne shell (sh(1))
# and Bourne compatible shells (bash(1), ksh(1), ash(1), ...).


if [ -d /etc/profile.d ]; then  <==判断读取目录 /etc/profile.d 目录下的sh脚本
  for i in /etc/profile.d/*.sh; do
    if [ -r $i ]; then
      . $i
    fi
  done
  unset i
fi
#以上就是读取目录 /etc/profile.d 下的sh脚本,而我们通过查看,发现该目录下只有一个文件:speechd-user-port.sh

#而且该文件里面只有一条语句:export SPEECHD_PORT=$(expr 6560 + $(getent passwd $USER | cut -f 3 -d :))

#显然是设置了一个环境变量SPEECHD_PORT,其值是6560与一个数x的和,而这个x为getent passwd $USER | cut -f 3 -d : 的结果

#我们运行这个命令getent passwd $USER  得到:root:x:0:0:root:/root:/bin/bash,而该结果与/etc/passwd中root对应的行一致。然后对该行以“:”为分隔符取第三个域,即为0。

#我们知道/etc/passwd文件中每一行的内容为:登陆名:可选的加密后的密码:userid:groupid:用户名:用户的家目录:用户默认shell,则,

#这个环境变量就是6560+userid 

if [ "$PS1" ]; then
  if [ "$BASH" ]; then
    PS1='\u@\h:\w\$ '
    if [ -f /etc/bash.bashrc ]; then
        . /etc/bash.bashrc
    fi
  else
    if [ "`id -u`" -eq 0 ]; then
      PS1='# '
    else
      PS1='$ '
    fi
  fi
fi
#以上这段是设置用户的命令提示符并读取配置文件/etc/bash.bashrc

umask 022

#设置文件掩码022

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值