ubuntu (Kubuntu) PATH相关脚本启动顺序

来源:互联网 发布:java 二进制流 编辑:程序博客网 时间:2024/04/30 19:31

环境:

ubuntu 12.04 + KDE + zsh

在Linux中如何修改PATH变量这个网上资料很多,本文简单介绍一下Kubuntu下PATH是如何构造出来的。

当默认使用kde作为启动桌面时,kdm会读取其配置文件/etc/kde4/kdm/Xsession,笔者机器上该脚本内容如下:

#! /bin/sh# Xsession - run as usersession=$1# Note that the respective logout scripts are not sourced.case $SHELL in  */bash)    [ -z "$BASH" ] && exec $SHELL $0 "$@"    set +o posix    [ -f /etc/profile ] && . /etc/profile    if [ -f $HOME/.bash_profile ]; then      . $HOME/.bash_profile    elif [ -f $HOME/.bash_login ]; then      . $HOME/.bash_login    elif [ -f $HOME/.profile ]; then      . $HOME/.profile    fi    ;;  */zsh)    [ -z "$ZSH_NAME" ] && exec $SHELL $0 "$@"    emulate -R zsh    [ -d /etc/zsh ] && zdir=/etc/zsh || zdir=/etc    zhome=${ZDOTDIR:-$HOME}    # zshenv is always sourced automatically.    [ -f $zdir/zprofile ] && . $zdir/zprofile    [ -f $zhome/.zprofile ] && . $zhome/.zprofile    [ -f $zdir/zlogin ] && . $zdir/zlogin    [ -f $zhome/.zlogin ] && . $zhome/.zlogin    setopt shwordsplit noextendedglob    ;;...(省略)...esac# invoke global X session script. /etc/X11/Xsession

可以看出,如果shell为bash,则首先加载

  1. /etc/profile

    1. . /etc/bash.bashrc
  2. $HOME/.bash_profile

  3. $HOME/.bash_login

  4. $HOME/.profile
    1. HOME/.bashrc

在ubuntu12.04上,$HOME/.bash_profile与 $/HOME/.bash_login都不存在。

如果将zsh作为默认shell,其脚本加载路径为/etc/zsh/zprofile,$HOME/.zprofile,$HOME/zlogin,$HOME/.zlogin

遗留的问题:默认shell为zsh时,没有去加载etc/profile以及$HOME/.profile?但是在.profile中添加echo命令却会被打印出来,这是为什么呢?

0 0
原创粉丝点击