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):
.profile
is for things that are not specifically related to Bash, like environment variablesPATH
and friends, and should be available anytime. For example,.profile
should also be loaded when starting a graphical desktop session..bashrc
is for the configuring the interactive Bash usage, like Bash aliases, setting your favorite editor, setting the Bash prompt, etc..bash_profile
is for making sure that both the things in.profile
and.bashrc
are loaded for login shells. For example,.bash_profile
could be something simple like
. ~/.profile . ~/.bashrc
As stated in the man page excerpt above, if you would omit
.bash_profile
, only.profile
would 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.
相关文章
- I bumped into a girl literally_back and forth
- bash 安全漏洞-Bash软件安全漏洞及修复方法
- ORA-23515: materialized views and/or their indices exist in the tablespace ORACLE 报错 故障修复 远程处理
- ORA-26826: string apply coordinator and apply slave are unable to communicate. ORACLE 报错 故障修复 远程处理
- ORA-27424: calendar clauses string and string are incompatible ORACLE 报错 故障修复 远程处理
- ORA-39339: Table string was skipped due to transportable import and TSTZ issues resulting from time zone version mismatch. ORACLE 报错 故障修复 远程处理
- MySQL Error number: MY-010460; Symbol: ER_INIT_DATADIR_EXISTS_AND_NOT_WRITABLE_WONT_INITIALIZE; SQLSTATE: HY000 报错 故障修复 远程处理
- ORA-01875: time zone minute must be between -59 and 59 ORACLE 报错 故障修复 远程处理
- Akka(42): Http:身份验证 – authentication, authorization and use of raw headers详解编程语言
- mybatis 处理数组类型及使用Json格式保存数据 JsonTypeHandler and ArrayTypeHandler详解编程语言
- ABAP Subscreen and tabstrip controls详解编程语言
- Create a nice looking chart with CL_GUI_CHART_ENGINE – Part 3 – Chart Data and render详解编程语言
- MySQL中的OR与AND操作符比较(mysqlor和and)
- 多条件查询MySQL中使用And多条件查询的步骤(mysql中and)
- 编程探索Linux下的Bash编程之旅(linux的bash)
- Linux中Bash:一种强大的 shell 编程语言(linux中bash是什么)
- Linux下的Bash编程简介(linux中的bash)
- 版本Linux查看Bash版本: 一步一步指南(linux查看bash)
- Linux安装Bash:轻松搞定让IT更好用(linux安装bash)
- 深入浅出:MySQL中AND和OR运算符使用方法(mysql中and和or)
- A Guide to Updating Your MySQL Database: Best Practices and Tips(mysqlupd)
- Exploring the Power and Versatility of Neo4j: Navigate and Analyze Data Like Never Before(neo4j)
- Exploring the Benefits and Features of Oracle 11i: An Essential Guide for Business Owners and Managers.(oracle11i)
- Exploring the Functions and Applications of Eth0 in Linux(linux中的eth0)
- 如何在Linux中修改Bash默认设置(linux修改bash)
- Linux中操作系统学习:Bash命令(linux中bash命令)
- 深入探究Mysql中IN与AND逻辑运算的应用(mysql中in与and)
- MySQL中AND的使用方法及含义解析(mysql中and的含义)
- MySQL中的AND和OR使用逻辑运算符优化查询语句(mysql中and与or)
- 数据使用Bash快速读取MySQL数据(bash 读取mysql)
- 使用Bash脚本简化MySQL数据库连接(bash能连接mysql)
- Oracle中使用除了And的其他查询关键字(oracle中除了and)
- Oracle 数据库中使用AND拼接的威力(oracle中and拼接)