bashrc,bash_profile和/etc/profile

最近老出现在shell里面能跑的程序用鼠标双击app去不能跑.究其原因是因为环境变量的问题.

在类unix系统中一般有三个bash配置文件:

  • ~/.bashrc 当前用户使用的配置文件
  • ~/.bash_profile 当前用户使用的配置文件
  • /etc/profile 所有用户都会继承的环境配置文件

我们需要搞清楚/etc/profile, ~/.bash_profile和~/.bashrc这几个文件的加载顺序.

一般来说~/.bash_profile > ~/.bash_rc > /etc/profile, 也就是说当没有找到bash_profile则使用bashrc再没找到就用/etc/profile

有兴趣的可以参考这篇博文: http://blog.galeo.me/post/23467503436/path-environment-variable-on-mac-os-x-emacs-app

在MacOSX的shell中读取的是.bash_profile,而不读取.bashrc.有两个配置也挺让人头痛的,不过stackoverflow给出了解决方案

Terminal opens a login shell. This means, ~/.bash_profile will get executed, ~/.bashrc not. The solution on most systems is to „require“ the ~/.bashrc in the ~/.bash_profile: just put this snippet in your ~/.bash_profile:

[[ -s ~/.bashrc ]] && source ~/.bashrc

最新文章

  1. windows编程:资源和播放声音
  2. C++ VS2012 内存泄露检测
  3. 【转】Struts2解决表单重复提交问题
  4. python流程控制语句 ifelse - 3
  5. [01] Preparation - Sitecore Installment
  6. 自定义ScriptableObject属性显示
  7. 从0打卡leetcode之day 6--最长回文串
  8. Elasticsearch 创建以及修改索引结构
  9. Java并发编程随笔
  10. python列表和字符串的三种逆序遍历方式
  11. 【linux】linux查找功能
  12. 【docker】docker安装和使用
  13. AI 朴素贝叶斯分类
  14. java集合框架中Set和List的区别
  15. oracle如何删除表空间
  16. TortoiseGit bonobo gitserver记住帐号密码
  17. 笔记1:MYSQL
  18. CF1060C Maximum Subrectangle【乘法分配律】【最大子矩阵】
  19. ryu 下发流表配置
  20. 安装FFmpeg3.0.9

热门文章

  1. 微信小程序,开发者工具更新以后wxss编译错误
  2. 使用Javascript实现ajax示例
  3. 简化js--函数返回
  4. matlab的输出流控制
  5. IDEA/Pycharm/Webstorm项目目录中的 Scratches and Consoles作用
  6. Docker创建centos的LNMP镜像
  7. reconstruct-original-digits-from-english(好)
  8. Verilog语法
  9. Jpeglib读取jpg文件 【转】
  10. 详解java中的数据结构