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. 用JSP生成HTM网页,减轻数据库操作

    原文:http://www.jspkongjian.net/news.jsp?id=396 此教程的功能: 利用servlet 实现抓取一个网页,把这个网页保存为.htm  比如抓取我们的主页inde ...

  2. IngressController的session stick问题

    周末爬坑,IngressController恢复因为镜像下载和版本问题折腾一下午,晚上终于折腾出个眉目. 首先,在Kubernetes的service中是可以设置Session Affinity的.例 ...

  3. LaTex:图片排版

    一般支持三种格式的图片排版 %% if you use PostScript figures in your article %% use the graphics package for simpl ...

  4. jquery获取li里面的第一个a标签

    $("li").children("a:eq(0)") ; children()查找子元素,eq() 查找第几个 $('.active').children(& ...

  5. 第二章:ES索引说明

    1."_boost": 20评分的权重(排序) 2."analyzer": "ik"中文分词 "analyzer": & ...

  6. Android之旅七 Service简介

    1.          Service是什么:它是一个应用程序组件.没有图形化界面.通常用来处理一些耗时比较长的操作(例如下载.播放MP3等等).可以使用Service更新ContentProvide ...

  7. 解决:mysql5.7 timestamp默认值‘0000-00-00 00:00:00’报错

    mysql5.7 运行sql脚本时报错 - Invalid default value for 'UPDATE_TIME' [Err] CREATE TABLE `V_TBL_AMOUNT_REASO ...

  8. ModelAndView command

    new ModelAndView("student", "command", new Student()); 对“如果在JSP中使用<form:form& ...

  9. vb.net小试三层架构

    在对三层架构有了初步了解后,用vb.net做了一个小的程序,真的很小,仅仅是为了体现一下三层之间机制.下面是我设计的操作界面: 还有程序集和类的分布情况, 接下来是数据的设计,数据库用到的是SQL S ...

  10. vc 获取函数名称真实地址

    首先写一个很简单的main函数: int main(){ printf("main的地址(?):%08x",main); } 单步调试,可得知 main函数的真实入口地址是:00b ...