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