在添加环境变量的时候,我们会去修改配置文件

如果留意过,网上博文,有些在/etc/profile文件中配置的,有些是在~./bash_profile文件中配置的,等等

那么,/etc/profile、~/.profile、~/.bashrc、~./bash_profile这几个配置文件有什么区别呢?

~/.profile ~/.bashrc和~./bash_profile

.bashrc

The individual per-interactive-shell startup file.

这个文件主要保存个人的一些个性化设置,如命令别名、路径等。定义了路径,语言,命令别名(使用rm删除命令时总是加上-i参数需要用户确认,使用ls命令列出文件列表时加上颜色显示)。每次修改.bashrc后,使用source ~/.bashrc就可以立刻加载修改后的设置,使之生效。一般会在.bash_profile文件中显式调用.bashrc。

登陆linux启动bash时首先会去读取/.bash_profile文件,里面会调用/.bashrc,这样/.bashrc也就得到执行了,你的个性化设置也就生效了

全局profile和用户下的~/.profile

用户可以在Profile文件中加入环境变量,比如JAVA_HOME...这样重新登录之后,这些环境变量都会得以设置,不用每次都手工设置。

Unix/Linux有两个profile文件

1./etc/profile:是全局profile文件,设置后会影响到所有用户

2./home/username/.profile或.bash_profile是针对特定用户的,可以针对用户,来配置自己的环境变量。

注意:profile是unix上才有的;bash_profile是Linux下有的(Linux下,用户目录没有.profile文件)

/home/username/.profile或.bash_profile,都是隐藏文件,需要使用ls -a才能看到。

Bash登陆(login)的时候,Profile执行的顺序

1)先执行全局Profile, /etc/profile

接着bash会检查使用者的HOME目录中,是否有 .bash_profile 或者 .bash_login或者 .profile,若有,则会执行其中一个,执行顺序为:

.bash_profile 最优先 > .bash_login其次 > .profile 最后

总之,就是全局或者局部,他们之间有调用关系及调用优先级

参考:https://www.jianshu.com/p/b39fd35e2360

linux的/etc/profile、~/.profile、~/.bashrc、~./bash_profile这几个配置文件的更多相关文章

  1. /etc/rc.local ; /etc/init.d ;/etc/profile;/etc/bashrc;~/.bash_profile;~/.bashrc;~/.bash_logout

    1. /etc/rc.local 这是使用者自订开机启动程序,把需要开机自动运行的程序写在这个脚本里. 把脚本程序写在/etc/rc.d/init.d/目录下也可以  在完成 run level 3 ...

  2. /etc/profile /etc/bashrc ~/.bash_profile ~/.bashrc ~/.bash_logout 说明及区别

    /etc/profile:此文件为系统的每个用户设置环境信息,当用户第一次登录时,该文件被执行. 并从/etc/profile.d目录的配置文件中搜集shell的设置. /etc/bashrc:为每一 ...

  3. etc/profile /etc/bashrc ~/.bash_profile ~/.bashrc等配置文件区别

    什么是交互式shell和非交互式shell,什么是login shell 和non-login shell. 交互式模式:就是shell等待你的输入,并且执行你提交的命令.这种模式被称作交互式是因为s ...

  4. Linux profile1,bashrc,.bash_profile,.bash_login,.profile,.bashrc,.bash_logout浅析 Part1

    profile,bashrc,.bash_profile,.bash_login,.profile,.bashrc,.bash_logout浅析 Part 1   by:授客 QQ:103355312 ...

  5. linux关于profile 、bashrc 、.bash_profile、.bashrc的区别

    linux关于profile .bashrc ..bash_profile..bashrc的区别 - /etc/profile /etc/bashrc ~/.bash_profile ~/.bashr ...

  6. Linux 启动时profile、bashrc、~/.bash_profile、~/.bashrc、~/.bash_profile执行顺序以及文件说明

    Linux 启动时profile.bashrc.~/.bash_profile.~/.bashrc.~/.bash_profile执行顺序以及文件说明 一.执行顺序 登录linux时,/etc/pro ...

  7. linux下/etc/profile /etc/bashrc /root/.bashrc /root/.bash_profile这四个配置文件的加载顺序

    目录 一.关于linux配置文件 二.验证四个配置文件的加载顺序 三.结论 一.关于linux配置文件 1.linux下主要有四个配置文件:/etc/profile ./etc/bashrc ./ro ...

  8. Linux中profile与bashrc的作用

    文章同步发表在博主网站朗度云,传输门:http://www.wolfbe.com/detail/201608/278.html 在Linux系统上,我们会看到类似于profile和bashrc的文件, ...

  9. profile bashrc bash_profile之间的区别和联系

    profile bashrc bash_profile之间的区别和联系 博客分类: Linux   执行顺序为:/etc/profile -> (~/.bash_profile | ~/.bas ...

随机推荐

  1. 吐血bug-- 多个input框接连blur事件导致alert接连弹出

    本来今天想记录一下Flow在vue源码中的应用,结果临时触发了个bug... bug描述: elementUi + Vue 技术 需求:一个表格中有至少两条数据,每条数据都有input框,在失去焦点后 ...

  2. Cookie 数据浅谈

    Cookie 是一些数据, 存储于你电脑上的文本文件中. 当 web 服务器向浏览器发送 web 页面时,在连接关闭后,服务端不会记录用户的信息.   Cookie 的作用就是用于解决 "如 ...

  3. Kotlin 扩展——省略findViewById

    现在 Kotlin 安卓扩展插件能够提供与这些开源库功能相同的体验,不需要添加任何额外代码. import kotlinx.android.synthetic.main.activity_main.* ...

  4. Jenkins 配置GitLab插件和Git插件

    本文演示如何在安装完Jenkins之后,配置GitLab插件和Git插件. 1 安装插件 浏览器登录Jenkins Web UI,点击系统管理,再点击管理插件,切换到可选插件,分别搜索GitLab P ...

  5. JS倒计时两种种实现方式

    最近做浏览器界面倒计时,用js就实现,两种方式: 一:设置时长,进行倒计时.比如考试时间等等 代码如下: <html> <head> <meta charset=&quo ...

  6. 企业移动化?AppCan教你正确的打开方式

    七分选型.三分软件.的确,在过去的企业移动化进程中,由于选型失败导致信息系统实施失败的案例屡见不鲜.而在当今的移动互连和大数据时代,移动化已经是企业必然的选择. 那么,什么是企业移动化呢?怎样才是企业 ...

  7. Cordova入门系列(一)创建项目 转发 https://www.cnblogs.com/lishuxue/p/6008678.html

    版权声明:本文为博主原创文章,转载请注明出处 Cordova是什么? 初学Cordova的人,虽然了解一点点,知道Cordova是用来将html, css, js变成app的,但并不知道到底是怎么用的 ...

  8. Luogu4655 [CEOI2017]Building Bridges

    Luogu4655 [CEOI2017]Building Bridges 有 \(n\) 根柱子依次排列,每根柱子都有一个高度.第 \(i\) 根柱子的高度为 \(h_i\) . 现在想要建造若干座桥 ...

  9. 吐血总结|史上最全的MySQL学习资料!!

    在日常工作与学习中,无论是开发.运维.还是测试,对于数据库的学习是不可避免的,同时也是日常工作的必备技术之一.在互联网公司,开源产品线比较多,互联网企业所用的数据库占比较重的还是MySQL. 在刚刚出 ...

  10. django.db.utils.ProgrammingError: (1146, "Table 'db_gold.user_ip_info' doesn't exist") RuntimeError: Model class scanhosts.models.HostLoginInfo doesn't declare an explicit app_label and isn't in an a

    Error Msg 创建了一个apps的目录将所有app放入apps文件中, 将apps路径加入sys.path中:sys.insert(0, os.path.join(BASE_DIR, " ...