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的更多相关文章

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

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

  2. Bash: about .bashrc, .bash_profile, .profile, /etc/profile, etc/bash.bashrc and others

    Some interesting excerpts from the bash manpage:When bash is invoked as an interactive login shell, ...

  3. profile,bashrc,.bash_profile,.bash_login,.profile,.bashrc,.bash_logout浅析 Part 2

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

  4. /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 ...

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

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

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

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

  7. linux profile\bashrc\bash_profile之间的区别和联系

    /etc/profile 每个用户,首次登录时被执行: /etc/bashrc 每个运行bash shell的用户都执行此文件,当bsh被打开时,该文件被读取: ~/.bash_profile 专用于 ...

  8. linux /etc/profile bashrc bash_profile

    文件: /etc/profile  ~/.bashrc  和  ~/.bash_profile 的使用区别: /etc/profile: 全局 环境变量等,在机器重启后执行一次, 用于设置环境变量,更 ...

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

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

随机推荐

  1. 微信小程序,工具未检测合法域名,400 (Bad Request)错误

    1.工具未检测合法域名 这个我就不多说了,如果你新建的时候没有填写AppID的话这个我就不太清楚了 如果新建项目的时候填写了AppID的话,出现这种错误,那你应该去小程序后台 设置->开发者设置 ...

  2. 关于 js 中的回调函数 callback

    本文写于1年前 曾经的学习文章如今拿出来分享 前言 其实我一直很困惑关于js中的callback,困惑的原因是,学习中这块看的资料少,但是平时又经常见,偶尔复制一下前人代码,功能实现了也就不再去追其原 ...

  3. android源码包下载

    http://rgruet.free.fr/public/ 其他下载地址:http://cid-b50f9d5897331c44.office.live.com/browse.aspx/Android ...

  4. Android 卡顿优化 4 布局优化实际技巧

    今天分享一些layout布局书写中的一些技巧,希望看过之后你也一样可以写出性价比高的布局.我个人的目标是用最少的View写出一样效果的布局.因为我相信View的数量减少伴随着的就是层级的减少.从而达到 ...

  5. pgfplots画二维图真的很方便,多例比较

    %直接PDFLATEX编译即可\documentclass[border=1mm]{standalone}\usepackage{tkz-euclide,pgfplots}\begin{documen ...

  6. ElasticSearch调优问题

    1. 近期遇到一个ES内存居高不下的问题,查了查,发现ES有个fielddata,当你发起一个查询,分析字符串的聚合将会被加载到 fielddata,如果这些字符串之前没有被加载过.如果结果中 fie ...

  7. 十一.spring-boot 添加http自动转向https

    SSL是为网络通信提供安全以及保证数据完整性的的一种安全协议,SSL在网络传输层对网络连接进行加密. 例:cas 的单点登陆就用到了SSL 一.安全证书的生成 1.可以使用jdk自带的证书生成工具,j ...

  8. Linux系统下,启动Tomcat有时报Address already in use

    一.Linux系统下,启动Tomcat有时报Address already in use<null>... 1.那是因为你的tomcat已经启动了tomcat自带的关闭脚本,有时候关闭看上 ...

  9. iOS:CYLTabBarController的具体使用实例:实现新浪微博的主流框架

    使用CocoaPods或者手动集成将CYLTabBarController这个第三方框架导入项目后,截图如下: 在AppDelegate.m类中实现的代码如下: // AppDelegate.m // ...

  10. iOS:延时执行的三种方式

    延时执行的三种方式:performSelectorXXX方法.GCD中延时函数.创建定时器   第一种方式:NSObject分类当中的方法,延迟一段时间调用某一个方法 @interface NSObj ...