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 ...
随机推荐
- bash处理一条命令的步骤
Shell执行一条命令步骤 参考链接: <Learning the bash Shell, 3rd Edition -- 7.3. Command-Line Processing> &l ...
- android studio报Resolved versions for app (26.1.0) and test app (27.1.1)differ. 错误的解决办法
https://blog.csdn.net/qq_36636969/article/details/80278150
- Buy the Ticket HDU 1133
传送门 [http://acm.hdu.edu.cn/showproblem.php?pid=1133] 题目描述和分析 代码 #include<iostream> #include< ...
- 20135316王剑桥Linux内核学习记笔记第七周
20135316王剑桥<Linux内核分析>MOOC课程http://mooc.study.163.com/course/USTC 1000029000 一.可执行程序是怎么得来的? 编译 ...
- ros-安装
1.安装了ubuntu for ros. 运行评论下边那条命令: 2.rtabamp 3.准备安装机器人导航仿真系统:https://blog.csdn.net/wangchao7281/articl ...
- SSH框架开发蛋糕房管理系统之质量属性
SSH框架开发蛋糕房管理系统之质量属性 我要开发的系统是基于ssh框架的蛋糕房管理系统.本系统前台提供的主要功能是在线预定蛋糕,本店管理员拥有最高权限,包括收银管理,设备管理,日常销售管理,蛋糕定制管 ...
- 关于QQ的NABCD模型
组名:思甜雅 关于QQ的NABCD模型 N--Need 随着电脑的普及,人们需要在网络上进行交流,现有的交流工具不够完善,不能够全部满足人们对于交流沟通中的需要. 初步了解人们的需求,人们需要一款可以 ...
- ChangeSort
package com.home.test; import java.util.Arrays; public class ChangeSort { public String[] changeLoca ...
- EnglishGame
https://github.com/zhangxue520/EnglishGame/blob/master/EnglishGame <程序设计实践I> 题目: 打字训练测试软 ...
- Maven的课堂笔记1
1 什么是maven? Maven是一个跨平台的项目管理工具,主要用于基于java平台的项目构建,依赖管理. Clean compile test package install run ...