/etc/profile和/etc/bashrc和~/.bash_profile和~/.bashrc和~/.bash_logout的区别

Shell配置文件详解
本文详细解析了Linux系统中各类Shell配置文件的作用与区别,包括全局配置文件/etc/profile及用户个性化配置文件如~/.bashrc等,并阐述了它们之间的执行顺序与继承关系。
/etc/profile:此文件为系统的每个用户设置环境信息,当用户第一次登录时,该文件被执行.
并从/etc/profile.d目录的配置文件中搜集shell的设置.
/etc/bashrc:为每一个运行bash shell的用户执行此文件.当bash shell被打开时,该文件被读取.
~/.bash_profile:每个用户都可使用该文件输入专用于自己使用的shell信息,当用户登录时,该
文件仅仅执行一次!默认情况下,他设置一些环境变量,执行用户的.bashrc文件.
~/.bashrc:该文件包含专用于你的bash shell的bash信息,当登录时以及每次打开新的shell时,该
该文件被读取.
~/.bash_logout:当每次退出系统(退出bash shell)时,执行该文件.

另外,/etc/profile中设定的变量(全局)的可以作用于任何用户,而~/.bashrc等中设定的变量(局部)只能继承/etc/profile中的变量,他们是"父子"关系.

~/.bash_profile 是交互式、login 方式进入 bash 运行的
~/.bashrc 是交互式 non-login 方式进入 bash 运行的
通常二者设置大致相同,所以通常前者会调用后者。
[root@centos-linux ~]# yum remove docker \ > anaconda-ks.cfg .cache/ initial-setup-ks.cfg .bash_logout .config/ .tcshrc .bash_profile .cshrc .xauth4ZflpI .bashrc .dbus/ .Xauthority > anaconda-ks.cfg .cache/ initial-setup-ks.cfg .bash_logout .config/ .tcshrc .bash_profile .cshrc .xauth4ZflpI .bashrc .dbus/ .Xauthority > anaconda-ks.cfg .cache/ initial-setup-ks.cfg .bash_logout .config/ .tcshrc .bash_profile .cshrc .xauth4ZflpI .bashrc .dbus/ .Xauthority > anaconda-ks.cfg .cache/ initial-setup-ks.cfg .bash_logout .config/ .tcshrc .bash_profile .cshrc .xauth4ZflpI .bashrc .dbus/ .Xauthority > docker-client \ 已加载插件:fastestmirror, langpacks 参数 docker 没有匹配 参数 docker-client 没有匹配 参数 没有匹配 不删除任何软件包 [root@centos-linux ~]# anaconda-ks.cfg .cache/ initial-setup-ks.cfg .bash_logout .config/ .tcshrc .bash_profile .cshrc .xauth4ZflpI .bashrc .dbus/ .Xauthority [root@centos-linux ~]# anaconda-ks.cfg .cache/ initial-setup-ks.cfg .bash_logout .config/ .tcshrc .bash_profile .cshrc .xauth4ZflpI .bashrc .dbus/ .Xauthority [root@centos-linux ~]# anaconda-ks.cfg .cache/ initial-setup-ks.cfg .bash_logout .config/ .tcshrc .bash_profile .cshrc .xauth4ZflpI .bashrc .dbus/ .Xauthority [root@centos-linux ~]# anaconda-ks.cfg .cache/ initial-setup-ks.cfg .bash_logout .config/ .tcshrc .bash_profile .cshrc .xauth4ZflpI .bashrc .dbus/ .Xauthority [root@centos-linux ~]# docker-client-latest \ bash: docker-client-latest: 未找到命令... [root@centos-linux ~]# anaconda-ks.cfg .cache/ initial-setup-ks.cfg .bash_logout .config/ .tcshrc .bash_profile .cshrc .xauth4ZflpI .bashrc .dbus/ .Xauthority [root@centos-linux ~]# anaconda-ks.cfg .cache/ initial-setup-ks.cfg .bash_logout .config/ .tcshrc .bash_profile .cshrc .xauth4ZflpI .bashrc .dbus/ .Xauthority [root@centos-linux ~]# anaconda-ks.cfg .cache/ initial-setup-ks.cfg .bash_logout .config/ .tcshrc .bash_profile .cshrc .xauth4ZflpI .bashrc .dbus/ .Xauthority [root@centos-linux ~]# anaconda-ks.cfg .cache/ initial-setup-ks.cfg .bash_logout .config/ .tcshrc .bash_profile .cshrc .xauth4ZflpI .bashrc .dbus/ .Xauthority [root@centos-linux ~]# docker-common \ bash: docker-common: 未找到命令... [root@centos-linux ~]# anaconda-ks.cfg .cache/ initial-setup-ks.cfg .bash_logout .config/ .tcshrc .bash_profile .cshrc .xauth4ZflpI .bashrc .dbus/ .Xauthority [root@centos-linux ~]# anaconda-ks.cfg .cache/ initial-setup-ks.cfg .bash_logout .config/ .tcshrc .bash_profile .cshrc .xauth4ZflpI .bashrc .dbus/ .Xauthority [root@centos-linux ~]# anaconda-ks.cfg .cache/ initial-setup-ks.cfg .bash_logout .config/ .tcshrc .bash_profile .cshrc .xauth4ZflpI .bashrc .dbus/ .Xauthority [root@centos-linux ~]# anaconda-ks.cfg .cache/ initial-setup-ks.cfg .bash_logout .config/ .tcshrc .bash_profile .cshrc .xauth4ZflpI .bashrc .dbus/ .Xauthority [root@centos-linux ~]# docker-latest \ bash: docker-latest: 未找到命令... [root@centos-linux ~]# anaconda-ks.cfg .cache/ initial-setup-ks.cfg .bash_logout .config/ .tcshrc .bash_profile .cshrc .xauth4ZflpI .bashrc .dbus/ .Xauthority [root@centos-linux ~]# anaconda-ks.cfg .cache/ initial-setup-ks.cfg .bash_logout .config/ .tcshrc .bash_profile .cshrc .xauth4ZflpI .bashrc .dbus/ .Xauthority [root@centos-linux ~]# anaconda-ks.cfg .cache/ initial-setup-ks.cfg .bash_logout .config/ .tcshrc .bash_profile .cshrc .xauth4ZflpI .bashrc .dbus/ .Xauthority [root@centos-linux ~]# anaconda-ks.cfg .cache/ initial-setup-ks.cfg .bash_logout .config/ .tcshrc .bash_profile .cshrc .xauth4ZflpI .bashrc .dbus/ .Xauthority [root@centos-linux ~]# docker-latest-logrotate \ bash: docker-latest-logrotate: 未找到命令... [root@centos-linux ~]# anaconda-ks.cfg .cache/ initial-setup-ks.cfg .bash_logout .config/ .tcshrc .bash_profile .cshrc .xauth4ZflpI .bashrc .dbus/ .Xauthority [root@centos-linux ~]# anaconda-ks.cfg .cache/ initial-setup-ks.cfg .bash_logout .config/ .tcshrc .bash_profile .cshrc .xauth4ZflpI .bashrc .dbus/ .Xauthority [root@centos-linux ~]# anaconda-ks.cfg .cache/ initial-setup-ks.cfg .bash_logout .config/ .tcshrc .bash_profile .cshrc .xauth4ZflpI .bashrc .dbus/ .Xauthority [root@centos-linux ~]# anaconda-ks.cfg .cache/ initial-setup-ks.cfg .bash_logout .config/ .tcshrc .bash_profile .cshrc .xauth4ZflpI .bashrc .dbus/ .Xauthority [root@centos-linux ~]# docker-logrotate \ bash: docker-logrotate: 未找到命令... [root@centos-linux ~]# anaconda-ks.cfg .cache/ initial-setup-ks.cfg .bash_logout .config/ .tcshrc .bash_profile .cshrc .xauth4ZflpI .bashrc .dbus/ .Xauthority [root@centos-linux ~]# anaconda-ks.cfg .cache/ initial-setup-ks.cfg .bash_logout .config/ .tcshrc .bash_profile .cshrc .xauth4ZflpI .bashrc .dbus/ .Xauthority [root@centos-linux ~]# anaconda-ks.cfg .cache/ initial-setup-ks.cfg .bash_logout .config/ .tcshrc .bash_profile .cshrc .xauth4ZflpI .bashrc .dbus/ .Xauthority [root@centos-linux ~]# anaconda-ks.cfg .cache/ initial-setup-ks.cfg .bash_logout .config/ .tcshrc .bash_profile .cshrc .xauth4ZflpI .bashrc .dbus/ .Xauthority [root@centos-linux ~]# docker-engine bash: docker-engine: 未找到命令...
最新发布
09-26
评论
成就一亿技术人!
拼手气红包6.0元
还能输入1000个字符
 
红包 添加红包
表情包 插入表情
 条评论被折叠 查看
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值