Linux中profile与bashrc的作用
文章同步发表在博主网站朗度云,传输门:http://www.wolfbe.com/detail/201608/278.html
login shell;
non-login shell;
interactive shell;
non-interactive shell;(非交互式,如执行shell脚本)
- 登录系统时,获得的是一种交互式的login shell;
- 在终端下使用--login参数调用bash时,获得的是交互式的login shell,如果不加--login参数,则获得的是交互式的non-login shell;
- 在脚本中使用--login选项调用bash时,获得的是非交互式的login shell(如#! /bin/bash),如果不加--login选项,则获得的是非交互式的non-login shell;
- 使用su -切换用户时,获得的是交互式的login shell,如果不加"-"获得的是交互式的non-login shell。
- 交互式login shell启动时首先读取/etc/profile文件信息,一般会在/etc/profile加载/etc/bashrc文件,然后依次查找~/.bash_profile、~/.bash_login、~/.profile配置文件,并且读取找到的第一个且可读的文件,最后再读取~/.bashrc文件;login shell在退出时会读取~/.bash_logout文件;
- 交互式non-login shell启动时首先读取/etc/bashrc文件,然后读取~/.bashrc文件;
- 非交互式login shell启动时首先读取/etc/profile文件信息,但不会加载/etc/bashrc文件,然后依次查找~/.bash_profile、~/.bash_login、~/.profile配置文件,并且读取找到的第一个且可读的文件,但也不会再加载~/.bashrc文件;login shell在退出时会读取~/.bash_logout文件;
- 非交互式non-login shell启动时不会读取上面的配置文件,而是找到环境变量BASH_ENV,并且读取BASH_ENV中指定的文件的命令;
#/etc/profile
echo "invoke /etc/profile" #/etc/bash.bashrc
echo "invoke /etc/bash.bashrc" #~/.bashrc
echo "invoke .bashrc" #~/.profile
echo "invoke .profile" #~/.bash_logout
echo "invoke bash_logout"
#! /bin/bash --login
echo "invoke login.sh" #! /bin/bash
echo "invoke nologin.sh" #! /bin/bash
echo "invoke bash_env.sh" #.profile后加入BASH_ENV
export BASH_ENV=/home/wolfbe/bash_env.sh #立即生效
source ./.profile
$bash --login invoke /etc/bash.bashrc
invoke /etc/profile
invoke .bashrc
invoke .profile $exit logout
invoke bash_logout
$bash invoke /etc/bash.bashrc
invoke .bashrc $exit exit
$./login.sh invoke /etc/profile
invoke .profile
invoke login.sh
$./nologin.sh invoke bash_env.sh
invoke nologin.sh
Linux中profile与bashrc的作用的更多相关文章
- Linux中profile、bashrc、bash_profile之间的区别和联系
/etc/profile:此文件为系统的每个用户设置环境信息,当用户第一次登录时,该文件被执行.并从/etc/profile.d目录的配置文件中搜集shell的设置. 英文描述为: # /etc/pr ...
- (转) Linux中profile、bashrc、bash_profile之间的区别和联系
原文地址:http://blog.csdn.net/chenchong08/article/details/7833242 /etc/profile:此文件为系统的每个用户设置环境信息,当用户第一次登 ...
- 【转载】Linux中profile、bashrc、bash_profile之间的区别和联系
如果你想对所有的使用bash的用户修改某个配置并在以后打开的bash都生效的话可以修改这个文件,修改这个文件不用重启,重新打开一个bash即可生效.~/.bash_profile:每个用户都可使用该文 ...
- 【转】Linux中profile、bashrc、bash_profile之间的区别和联系
/etc/profile:此文件为系统的每个用户设置环境信息,当用户第一次登陆时,该文件被执行.并从/etc/profile.d目录的配置文件中搜集shell的设置. 英文描述为: # /etc/pr ...
- Linux中profile和bashrc的区别
profile主要设置系统环境参数(可类比为Windows的系统环境变量),如$PATH /etc/profile ~/.bash_profile bashrc主要用来设置bash命令,如命令别名,a ...
- Linux中PATH环境变量的作用和使用方法
关于PATH的作用:PATH说简单点就是一个字符串变量,当输入命令的时候LINUX会去查找PATH里面记录的路径.比如在根目录/下可以输入命令ls,在/usr目录下也可以输入ls,但其实ls这个命令根 ...
- linux关于profile 、bashrc 、.bash_profile、.bashrc的区别
linux关于profile .bashrc ..bash_profile..bashrc的区别 - /etc/profile /etc/bashrc ~/.bash_profile ~/.bashr ...
- linux中test与[ ]指令的作用
linux中test与[ ]指令的作用: 在Linux中,test和[ ]功能是一样的,类似于c语言中的( ).不过Linux的test和[ ]是指令.在和if或者while联用时要用空格分开.
- Linux中的Wheel组的作用
原文:http://www.360doc.com/content/11/0505/10/4644186_114496525.shtml Linux中的Wheel组的作用(用自己的话翻译的) (原文) ...
随机推荐
- 疑难杂症:org.hibernate.MappingException: Unknown entity,annotation配置Entity类报错
引言: 夜声人静,外面下着稀里哗啦的雨,周末的晚上,还在键盘上舞动手指. 此刻很感激一个人一篇随笔,感谢xiaochao以及他的<org.hibernate.MappingException: ...
- Golang学习 - errors 包
------------------------------------------------------------ Go 语言使用 error 类型来返回函数执行过程中遇到的错误,如果返回的 e ...
- Linux中/usr与/var目录详解
/usr文件系统 /usr 文件系统经常很大,因为所有程序安装在这里. /usr 里的所有文件一般来自Linux distribution:本地安装的程序和其他东西在/usr/local 下.这样可能 ...
- servlet 和filter 抛出404等异常
1. servlet抛出错误代码异常,如404 public void doGet(HttpServletRequest request, HttpServletResponse response) ...
- The Socket API, Part 5: SCTP
转:http://www.linuxforu.com/2011/12/socket-api-part-5-sctp/ By Pankaj Tanwar on December 29, 2011 in ...
- iso8583报文自学笔记
一.8583报文组成 TPDU 报文头 应用数据 ISO8583 Msg ID 目的 地址 源地址 应用类别定义 软件 总版本号 终端 状态 处理 要求 保留使用(软件分版本号) 交易数据 60H N ...
- SQL Server三种表连接原理
在SQL Server数据库中,查询优化器在处理表连接时,通常会使用一下三种连接方式: 嵌套循环连接(Nested Loop Join) 合并连接 (Merge Join) Hash连接 (Hash ...
- css居中的几种方式
居中分水平和垂直两种,使用的频度也算是很高,下面分情况来讨论一下几种常用的实现方式. 欢迎指正文中的错误,同时如果有学习到新的方式也会更新在后面,也方便以后温故知新. 1.margin 这种方式只能实 ...
- android网络请求之get方法
package com.jredu.helloworld.activity; import android.os.Bundle; import android.os.Handler; import a ...
- 移动端 viewport设置
<meta name="viewport" content="" /> width [pixel_value | device-width] wid ...