LinuxのユーザProfile

本文详细解析了Linux环境下bash作为登录shell启动时的配置文件加载顺序,包括/etc/profile、~/.bash_profile、~/.bash_login、~/.profile、~/.bashrc和/etc/bashrc的作用及用法,并对比了它们在不同启动场景下的行为。

○Linuxでbashがログインシェルとして起動する場合

ユーザ環境の設定ファイルは次の順番で読み込まれます。

1./etc/profileを読み込む
2.~/.bash_profile, ~/.bash_login, ~/.profile
    の順でファイルを検索して、最初に見つかったファイルを読み込む


~/.bash_profileが見つかった場合

3.~/.bash_profileから~/.bashrcを読み込む
4.~/.bashrcから/etc/bashrcを読み込む


RedHat AS4のデフォルトの~/.bash_profile

$ 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
unset USERNAME


RedHat AS4のデフォルトの~/.bashrc

$ cat ~/.bashrc
# .bashrc

# User specific aliases and functions

# Source global definitions
if [ -f /etc/bashrc ]; then
        . /etc/bashrc
fi



○bashをログイン時以外に起動した場合

1.~/.bashrcを読み込む
2.~/.bashrcから/etc/bashrcを読み込む



○設定ファイルの使い分け

/etc/profile:全ユーザに対して設定したい場合に使用。一回設定しておけば良い設定に使用。
~/.bash_profile:ユーザ個別に設定したい場合に使用。一回設定しておけば良い設定に使用。
~/.bashrc:エイリアス設定などシェル起動時に毎回設定する必要がある場合に使用。

转载于:https://www.cnblogs.com/chenbai/p/3631005.html

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值