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, or as a non-interactive shell with the --login option, it first reads and executes commands from the file /etc/profile, if that file exists. After reading that file, it looks for ~/.bash_profile,~/.bash_login, and ~/.profile, in that order, and reads and executes commands from the first one that exists and is readable. The --noprofile option may be used when the shell is started to inhibit this behavior.
...
When an interactive shell that is not a login shell is started, bash reads and executes commands from /etc/bash.bashrc and~/.bashrc, if these files exist. This may be inhibited by using the --norc option. The --rcfile file option will force bash to read and execute commands from file instead of /etc/bash.bashrc and ~/.bashrc.
As far as I understand, a login shell means a session where you log in to the system and directly end up in Bash, like a remote ssh session or logging in through a non-graphical text terminal. A non-login shell is then the type of shells you open after logging in: typically in a graphical session when you open a new terminal window.
How I think things are supposed to work (for a typical setup):
.profileis for things that are not specifically related to Bash, like environment variablesPATHand friends, and should be available anytime. For example,.profileshould also be loaded when starting a graphical desktop session..bashrcis for the configuring the interactive Bash usage, like Bash aliases, setting your favorite editor, setting the Bash prompt, etc..bash_profileis for making sure that both the things in.profileand.bashrcare loaded for login shells. For example,.bash_profilecould be something simple like. ~/.profile
. ~/.bashrcAs stated in the man page excerpt above, if you would omit
.bash_profile, only.profilewould be loaded.
You might also be interested in the page I put together with the most important stuff from my .bashrc, .profile and other files.
Bash: about .bashrc, .bash_profile, .profile, /etc/profile, etc/bash.bashrc and others的更多相关文章
- bashrc,bash_profile和/etc/profile
bashrc,bash_profile和/etc/profile 最近老出现在shell里面能跑的程序用鼠标双击app去不能跑.究其原因是因为环境变量的问题. 在类unix系统中一般有三个bash配置 ...
- /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 ...
- /etc/profile /etc/bashrc ~/.bash_profile ~/.bashrc ~/.bash_logout 说明及区别
/etc/profile:此文件为系统的每个用户设置环境信息,当用户第一次登录时,该文件被执行. 并从/etc/profile.d目录的配置文件中搜集shell的设置. /etc/bashrc:为每一 ...
- profile bashrc bash_profile之间的区别和联系
profile bashrc bash_profile之间的区别和联系 博客分类: Linux 执行顺序为:/etc/profile -> (~/.bash_profile | ~/.bas ...
- linux的/etc/profile、~/.profile、~/.bashrc、~./bash_profile这几个配置文件
在添加环境变量的时候,我们会去修改配置文件 如果留意过,网上博文,有些在/etc/profile文件中配置的,有些是在~./bash_profile文件中配置的,等等 那么,/etc/profile. ...
- ubuntu中环境变量文件/etc/profile、.profile、.bashrc、/etc/bash.bashrc之间的区别和联系
一 /etc/profile: 此文件为系统的每个用户设置环境信息,当用户第一次登录时,该文件被执行.并从/etc/profile.d目录的配置文件中搜集shell的设置.所以如果你有对/etc/pr ...
- 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 ...
- profile bashrc bash_profile 之间的区别和联系
/etc/profile:此文件为系统的每个用户设置环境信息,当用户第一次登录时,该文件被执行.并从/etc/profile.d目录的配置文件中搜集shell的设置. /etc/bashrc:为每一个 ...
- etc/profile /etc/bashrc ~/.bash_profile ~/.bashrc等配置文件区别
什么是交互式shell和非交互式shell,什么是login shell 和non-login shell. 交互式模式:就是shell等待你的输入,并且执行你提交的命令.这种模式被称作交互式是因为s ...
随机推荐
- jinja2模块使用教程
模板 要了解jinja2,那么需要先理解模板的概念.模板在Python的web开发中广泛使用,它能够有效的将业务逻辑和页面逻辑分开,使代码可读性增强.并且更加容易理解和维护. 模板简单来说就是一个其中 ...
- (理论篇)从基础文件IO说起虚拟内存,内存文件映射,零拷贝
为了快速构建项目,使用高性能框架是我的职责,但若不去深究底层的细节会让我失去对技术的热爱. 探究的过程是痛苦并激动的,痛苦在于完全理解甚至要十天半月甚至没有机会去应用,激动在于技术的相同性,新的框架不 ...
- Mvc_ActionResult返回值
//ViewResult 表示HTML的页面内容 //EmptyResult 表示空白的页面内容 //RedirectResult 表示定位到另外一个URL //JsonResult 表示可以运用到A ...
- java 定时器中任务的启动、停止、再启动
package com.cvicse.ump.timer.service; import java.util.Date; import java.util.Timer; import com.cvic ...
- PHP从入门到精通(四)
PHP数组中的常用函数汇总 为了更直观的讲解各函数的作用和用法,方便大家的理解,首先,我们来定义一个数组.下面各函数的操作将以本数组为例: $arr = array(1,2,3,4,5,6," ...
- IT行业的创新的读后感
一.什么是创新 创新是以新思维.新发明和新描述为特征的一种概念化过程.它原意有三层含义,第一,更新:第二,创造新的东西:第三,改变.创新是人类特有的认识能力和实践能力,是人类主观能动性的高级表现形式, ...
- 删除运行时权限不足,cmd开启管理员
管理员帐号活跃代码:net user administrator /active:yes 搜索cmd-右键以管理员身份运行 切换administrator帐号登录 操作后最后关闭这么高的权限,避免被非 ...
- pandas修改全列的时间格式 无需使用apply
df.date.dt.strftime('%Y%m%d') #实现全列修改时间格式
- An internal error has occurred. Java heap space
http://stackoverflow.com/questions/11001252/running-out-of-heap-space issue: I am having a heap spac ...
- 其他数据库的restful方式
1. mysql 的 xmysql https://blog.csdn.net/dev_csdn/article/details/78480522 2. Oracle 的ORDS https://bl ...