『ログイン時,全てのユーザーに参照される』

[root@localhost ~]# ls -l /etc/profile
-rw-r–r– 1 root root 937 11月 10 03:12 /etc/profile
基本的な環境変数などの設定をします。

===================================================

# ksh workaround
if [ -z “$EUID” -a -x /usr/bin/id ]; then
        EUID=`id -u`
        UID=`id -ru`
fi
HOSTNAME=`/bin/hostname`
HISTSIZE=3000
export PATH USER LOGNAME MAIL HOSTNAME HISTSIZE INPUTRC

for i in /etc/profile.d/*.sh ; do
    if [ -r “$i” ]; then
        . $i
    fi
done

unset i
===================================================

[root@localhost ~]# ls -l /etc/bashrc
-rw-r–r– 1 root root 1437 11月 28  2006 /etc/bashrc
[root@localhost ~]#

 

===================================================

if [ $UID -gt 99 ] && [ “`id -gn`” = “`id -un`” ]; then
        umask 002
else
        umask 022
fi
if [ “$PS1” ]; then
    case $TERM in
        xterm*)
                if [ -e /etc/sysconfig/bash-prompt-xterm ]; then
                        PROMPT_COMMAND=/etc/sysconfig/bash-prompt-xterm
                else
                PROMPT_COMMAND=’echo -ne “\033]0;${USER}@${HOSTNAME%%.*}:${PWD/#$HOME/~}”; echo -ne “\007″‘
                fi
                ;;
        screen)
                if [ -e /etc/sysconfig/bash-prompt-screen ]; then
                        PROMPT_COMMAND=/etc/sysconfig/bash-prompt-screen
                else
                PROMPT_COMMAND=’echo -ne “\033_${USER}@${HOSTNAME%%.*}:${PWD/#$HOME/~}”; echo -ne “\033\\”‘
                fi
                ;;
        *)
                [ -e /etc/sysconfig/bash-prompt-default ] && PROMPT_COMMAND=/etc/sysconfig/bash-prompt-default
            ;;
    esac
    # Turn on checkwinsize
    shopt -s checkwinsize
    [ “$PS1” = “\\s-\\v\\\$ ” ] && PS1=”[\u@\h \W]\\$ “
fi

if ! shopt -q login_shell ; then # We’re not a login shell
        # Need to redefine pathmunge, it get’s undefined at the end of /etc/profile
    pathmunge () {
                if ! echo $PATH | /bin/egrep -q “(^|:)$1($|:)” ; then
                        if [ “$2” = “after” ] ; then
                                PATH=$PATH:$1
                        else
                                PATH=$1:$PATH
                        fi
                fi
        }

        for i in /etc/profile.d/*.sh; do
                if [ -r “$i” ]; then
                        . $i
        fi
        done
        unset i
        unset pathmunge
fi
===================================================

 

『ログイン時にユーザーHOMEディレクトリーのファイルが参照される』

[root@localhost ~]# ls -l /home/admin/.bash_profile
-rw-r–r– 1 admin admin 219 10月  8 01:58 /home/admin/.bash_profile
===================================================

[root@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:/usr/bin/:/usr/sbin:/sbin:/usr/local/mysql

export PATH
[root@localhost ~]#
===================================================

 

[root@localhost ~]# ls -l /home/admin/.bashrc
-rw-r–r– 1 admin admin 124  1月  6  2007 /home/admin/.bashrc

ファイルのコピー,削除,移動などをする時に確認メッセージを表示したい時は以下のようにラインを追加。

alias rm=’rm -i’
alias cp=’cp -i’
alias mv=’mv -i’
===================================================

[root@localhost ~]# more .bashrc
# .bashrc

alias rm=’rm -i’
alias cp=’cp -i’
alias mv=’mv -i’
# Source global definitions
if [ -f /etc/bashrc ]; then
        . /etc/bashrc
fi

# User specific aliases and functions
[root@localhost ~]#

===================================================

[root@localhost ~]# ls -l /home/admin/.bash_logout
-rw-r–r– 1 admin admin 24  1月  6  2007 /home/admin/.bash_logout
[root@localhost ~]#
===================================================

[root@localhost ~]# cat .bash_logout
# ~/.bash_logout

clear
[root@localhost ~]#
===================================================

 

[root@localhost ~]# ls -l .bash_history
-rw——- 1 admin admin 19973 11月 10 03:21 .bash_history
[root@localhost ~]#

bashコマンドの履歴
===================================================

[root@localhost ~]# more .bash_history
cd ..
cd /usr/local/src/
ls
cd php-5.2.4
ls
make test
ls
make clean
===================================================

~/.bash_login , ~/.profile , ~/.inputrcなどもあります。

 

 2574 pts/0    Ss     0:00 -bash  <–ログインシェル
 2616 pts/0    S      0:00 /bin/bash
 2720 pts/0    R+     0:00 ps awx