首页 > 其他 > 详细

bashrc,bash_profile和/etc/profile

时间:2014-07-27 10:09:12      阅读:307      评论:0      收藏:0      [点我收藏+]

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

bashrc,bash_profile和/etc/profile

原文:http://www.cnblogs.com/clivelee/p/3870510.html

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!