/etc/profile
为系统的每个用户设置环境信息,当用户第一次登录时,该文件被执行,并从/etc/profile.d目录的配置文件中搜集shell的设置,etc/profile中设定的变量的可以作用于任何用户,而~/.bashrc等中设定的变量只能继承/etc/profile中的变量。
/etc/bashrc
为每一个运行bash shell的用户执行此文件,当bash shell被打开时,该文件被读取。
~/.bash_profile
用户都可使用该文件输入专用于自己使用的shell信息,当用户登录时,该文件被执行一次。它设置一些环境变量,执行用户的.bashrc文件。
~/.bashrc
该文件包含专用于你的bash shell的bash信息,当登录时以及每次打开新的shell时,该文件被读取。
~/.bash_logout
当每次退出bash shell时,执行该文件。
~/.bash_history
记录历史输入命令
我的系统中的相关文件如下所示,调用关系也很清楚。
# /etc/profile
# System wide environment and startup programs, for login setup
# Functions and aliases go in /etc/bashrc
pathmunge () {
if ! echo $PATH | /bin/egrep -q "(^|:)$1($|:)" ; then
if [ "$2" = "after" ] ; then
PATH=$PATH:$1
else
PATH=$1:$PATH
fi
fi
}
# ksh workaround
if [ -z "$EUID" -a -x /usr/bin/id ]; then
EUID=`id -u`
UID=`id -ru`
fi
# Path manipulation
if [ "$EUID" = "0" ]; then
pathmunge /sbin
pathmunge /usr/sbin
pathmunge /usr/local/sbin
fi
# No core files by default
ulimit -S -c 0 > /dev/null 2>&1
if [ -x /usr/bin/id ]; then
USER="`id -un`"
LOGNAME=$USER
MAIL="/var/spool/mail/$USER"
fi
JAVA_HOME=`/usr/java/jdk1.6.0_14`
HOSTNAME=`/bin/hostname`
HISTSIZE=1000
if [ -z "$INPUTRC" -a ! -f "$HOME/.inputrc" ]; then
INPUTRC=/etc/inputrc
fi
export PATH USER JAVA_HOME LOGNAME MAIL HOSTNAME HISTSIZE INPUTRC
for i in /etc/profile.d/*.sh ; do
if [ -r "$i" ]; then
. $i
fi
done
unset i
unset pathmunge
# .bash_profile
# Get the aliases and functions
if [ -f ~/.bashrc ]; then
. ~/.bashrc
fi
# User specific environment and startup programs
JAVA_HOME=/usr/java/jdk1.6.0_14
export JAVA_HOME
PATH=$PATH:$HOME/bin
BASH_ENV=$HOME/.bashrc
USERNAME="root"
export USERNAME BASH_ENV PATH
export LC_ALL=zh_CN.gb2312
export LANG=zh_CN.gb2312
export LANGUAGE=zh_CN.2312
unset USERNAME
vi .bashrc
# .bashrc
# User specific aliases and functions
alias rm='rm -i'
alias cp='cp -i'
alias mv='mv -i'
# Source global definitions
if [ -f /etc/bashrc ]; then
. /etc/bashrc
Fi
# ~/.bash_logout
clear
分享到:
相关推荐
详细介绍.bash_profile和.bashrc有什么区别
1.上面这三个文件是bash shell的用户环境配置文件,位于用户的主目录下。其中.bash_profile是最重要的一个配置文件,它在用户每次登录系统时...但一般 来说都会在.bash_profile里调用.bashrc脚本以便统一配置用户环境。
浅析linux 下的/etc/profile、/etc/bashrc、~/.bash_profile、~/.bashrc
terminal init的时候并不会执行~/.bash_profile、~/.bashrc等脚本了, 这是因为其默认启动执行脚本变为了~/.zshrc。 解决办法就是修改~/.zshrc文件,在其中添加: source ~/.bash_profile、~/.bashrc等脚本文件...
详细分析了.bash_profile和.bashrc的区别
/etc/bashrc 每个运行bash shell的用户都执行此文件,当bsh被打开时,该文件被读取; ~/.bash_profile 专用于本用户的shell信息,仅被执行一次; ~/.bashrc 文件包含本用户的bsh信息,登录及每次打开shell时被读取。
主要介绍了Linux下环境变量配置方法小结(.bash_profile和.bashrc的区别),本文给大家介绍的非常详细,对大家的学习或工作具有一定的参考借鉴价值,需要的朋友可以参考下
/etc/profile:此文件为系统的每个用户设置环境信息,当用户第一次登录时,该文件被执行. 并从/etc/profile.d目录的配置文件中搜集shell的设置.
bash-full-of-colors:高级.bashrc和.bash_profile以及彩色输出
ubuntuConfig 包含用于wsl ubuntu 20.04快捷方式的.bashrc,.bash_profile,.bash_aliases和.vimrc文件的存储库。
如果此处有 .env 目录,则在当前目录树中激活 Python virtualenv 的 .bash_profile 脚本 安装 添加到你的~/.bashrc文件中有几行: if [ -f ~ /.bash_profile ] ; then . ~ /.bash_profile fi
linux在启动过程中,会...如果~/.bash_profile文件存在的话,一般还会执行~/.bashrc。再理清下思路,/etc/profile是全局配置文件,适用于所有用户,其他用户目录的配置文件只适用于某个用户,对其他用户就不起作用了。
.bash_profile .Desktop_en .kde .Xauthority .abcuser.dict .bashrc .Desktop_gb .kderc .Xdefaults .abcuser.rem .cshrc .gnome .lynx_cookies .bash_history Desktop .gnome-desktop .sawfish 3、-A 显示...
下载本附件,放到你的用户主目录,在你的.bash_profile或者.bashrc,或者.profile里加入: if [ -f ~/.git-completion.bash ]; then . ~/.git-completion.bash fi 然后source一下或者重新登录,你的git就支持自动...
bash-full-of-colors - 高级.bashrc和.bash_profile并拥有彩色输出
例如 cd ~/.bash/git clone https://github.com/mocheng/gitbash然后,在您的~/.bashrc ,添加以下行 source ~/.bash/gitbash/git-prompt.shPS1="\u@:\w\[\e[1;32m\]\$(parse_git_branch_or_tag)\[\e[0m\]$"现在,...
# For Mac or Linux:打开命令行终端,执行 vim ~/.bash_profile ,键入:alias merge="sh /merge文件的路径/merge.sh",保存并退出,再执行:source ~/.bash_profile # 进入到Git管理的项目根目录,执行如下命令...
/etc/profile: 此文件为系统的每个用户设置环境信息,当用户... 另外,/etc/profile中设定的变量(全局)的可以作用于任何用户,而~/.bashrc等中设定的变量(局部)只能继承/etc/profile中的变量,他们是"父子"关系。