Bash: about .bashrc, .bash_profile, .profile, /etc/profile, etc/bash.bashrc and others
来源:互联网 发布:合肥百度seo教程 编辑:程序博客网 时间:2024/05/22 15:19
~/.bashrc
,~/.bash_profile
,~/.profile
,/etc/profile
,/etc/bash.bashrc
(and maybe others) and what their purposes are? I do.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, alogin 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. Anon-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 inthe page I put together with the most important stuff from my.bashrc
,.profile
and other files.
<come from http://stefaanlippens.net/bashrc_and_others>
- Bash: about .bashrc, .bash_profile, .profile, /etc/profile, etc/bash.bashrc and others
- 关于Debian中的/etc/.profile, /etc/bash.bashrc, ~/.bashrc, ~/.profile,
- Linux中的~/.profile,~/.bashrc,/etc/profile,/etc/bash.bashrc
- /etc/bash.bashrc、/etc/profile、终端 设置
- /etc/profile、/etc/bashrc、~/.bash_profile、~/.bashrc
- /etc/profile、/etc/bashrc、~/.bash_profile、~/.bashrc
- /etc/profile、/etc/bashrc、~/.bash_profile、~/.bashrc 比较
- /etc/profile /etc/bashrc ~/.bash_profile ~/.bashrc 区别
- /etc/profile、/etc/bashrc、~/.bash_profile、~/.bashrc
- /etc/profile、/etc/bashrc、~/.bash_profile、~/.bashrc
- /etc/profile、/etc/bashrc、~/.bash_profile、~/.bashrc
- /etc/profile,/etc/bashrc,~/.bash_profile,~/.bashrc
- /etc/profile、/etc/bashrc、~/.bash_profile、~/.bashrc
- Linux /etc/profile,~/.bash_profile,~/.bashrc,/etc/bashrc
- /etc/profile、/etc/bashrc、~/.bash_profile、~/.bashrc
- 关于bash启动脚本/etc/profile /etc/bashrc ~/.bash_profile ~/.bashrc的区别
- bash配置文件/etc/profile,/etc/bashrc,~/.bash_profile,~/.bashrc详解及修改PATH环境变量
- bash配置文件/etc/profile,/etc/bashrc,~/.bash_profile,~/.bashrc详解及修改PATH环境变量
- android 关于Toast重复显示解决方法
- Spider之Scrapy安装介绍
- 浅谈HOOK
- 后台调用js的方法
- nice命令
- Bash: about .bashrc, .bash_profile, .profile, /etc/profile, etc/bash.bashrc and others
- IOS学习笔记2—Objective C—类、属性、方法
- 有序单链表排序[面试题目]
- PaCS实施工作总结
- vector使用
- 串口转以太网将在 iMCU上运行
- shell变量
- 全球通用头像gravatar介绍
- linux proftp 配置