【.bash_profile 与 .bashrc 的区别】
【.bash_profile 与 .bashrc 的区别】
.bash_profile is executed for login shells, while .bashrc is executed for interactive non-login shells.
【login shell 与 non-login shell 的区别】
1、当你直接在机器login界面登陆、使用ssh登陆或者su切换用户登陆时,.bash_profile 会被调用来初始化shell环境
Note:.bash_profile文件默认调用.bashrc文件
.bash_profile中有如下内容
if [ -f ~/.bashrc ]; then
. ~/.bashrc
fi
2、当你不登陆系统而使用ssh直接在远端执行命令,.bashrc 会被调用
3、当你已经登陆系统后,每打开一个新的Terminal时,.bashrc 都会被再次调用。
测试准备工作
hclient2主机hadoop用户家目录下执行
[hadoop@hclient2 ~]$ echo "invoke hclient2:~/.bashrc">>.bashrc
[hadoop@hclient2 ~]$ echo "invoke hclient2:~/.bash_profile">>.bash_profile
Login Shell
1、窗口登陆
Red Hat Enterprise Linux Server release 6.3 (Santiago)
Kernel 2.6.32-279.el6.x86_64 on an x86_64
hclient2 login: hadoop
Password:
Last login: Mon Feb 25 23:03:45 on tty1
invoke hclient2:~/.bashrc
invoke hclient2:~/.bash_profile
[hadoop@hclient2 ~]$
2、SSH 登陆
[hadoop@hserver ~]$ ssh hclient2
Last login: Mon Feb 25 22:42:19 2013 from hserver
invoke hclient2:~/.bashrc
invoke hclient2:~/.bash_profile
[hadoop@hclient2 ~]$
3、su 登陆
[root@hclient2 ~]# su - hadoop
invoke hclient2:~/.bashrc
invoke hclient2:~/.bash_profile
Non-login Shell:
Note: ssh ...[user@] hostname [command]
If command is specified, it is executed on the remote host instead of a login shell.
[hadoop@hserver ~]$ ssh hclient2 hostname
invoke hclient2:~/.bashrc
hclient2
【故】若要配置环境变量之类,最保险是写在 .bashrc 文件中。因为不管是登陆还是不登陆,该文件总会被调用!
转载于:https://blog.51cto.com/caimengzhi/1700936
【.bash_profile 与 .bashrc 的区别】相关推荐
- Linux下环境变量配置方法梳理(.bash_profile和.bashrc的区别)
博客园 首页 新随笔 联系 管理 订阅 <div class="blogStats"><!--done--> 随笔- 556 文章- 38 评论- 77 ...
- linux 下/etc/profile、/etc/bashrc、~/.bash_profile、~/.bashrc 的区别
linux 下/etc/profile./etc/bashrc.~/.bash_profile.~/.bashrc 的区别 /etc/profile./etc/bashrc.~/.bash_profi ...
- Linux: .bash_profile 与 .bashrc 的区别
[.bash_profile 与 .bashrc 的区别] .bash_profile is executed for login shells, while .bashrc is executed ...
- linux环境变量又叫局部变量的区别,Linux下环境变量(.bash_profile和.bashrc的区别)...
在linux系统下,如果下载并安装了应用程序,在启动时很有可能在键入它的名称时出现"command not found"的提示内容.如果每次都到安装目标文件夹内,找到可执行文件 来 ...
- .bash_profile和.bashrc的区别(如何设置生效)
/etc/profile:此文件为系统的每个用户设置环境信息,当用户第一次登录时,该文件被执行. 并从/etc/profile.d目录的配置文件中搜集shell的设置. /etc/bashrc:为每一 ...
- .bash_profile和.bashrc的区别
/etc/profile:此文件为系统的每个用户设置环境信息,当用户第一次登录时,该文件被执行. 并从/etc/profile.d目录的配置文件中搜集shell的设置. /etc/bashrc:为每一 ...
- 关于“.bash_profile”和“.bashrc”区别的总结
bash的startup文件 Linux shell是用户与Linux系统进行交互的媒介,而bash作为目前Linux系统中最常用的shell,它支持的startup文件也并不单一,甚至容易让人感到费 ...
- /etc/profile、/etc/bashrc、~/.bash_profile、~/.bashrc 文件的作用
转载自:http://blog.csdn.net/u013968345/article/details/21262033 /etc/profile:此文件为系统的每个用户设置环境信息,当用户第一次登 ...
- linux启动 profile,Linux 启动时profile、bashrc、~/.bash_profile、~/.bashrc、~/.bash_profile执行顺序以及文件说明...
Linux 启动时profile.bashrc.~/.bash_profile.~/.bashrc.~/.bash_profile执行顺序以及文件说明 一.执行顺序 登录linux时,/etc/pro ...
- profile 和 bashrc 的区别
什么是 shell shell 简介 shell 是系统的用户界面,提供了用户与内核进行交互操作的一种接口.它接收用户输入的命令并把它送入内核去执行. shell 是一个命令解释器,它解释由用户输入的 ...
最新文章
- ERP与EWM集成配置-ERP端组织架构(二)
- 人均奖金300万,2021年“科学探索奖”名单揭晓:高会军周昆上榜,女性获奖人8位创纪录...
- linux java aptget_apt-get没有安装任何linux服务器
- JAVA类定义的修饰
- Android 中使用MediaRecorder进行录像详解(视频录制)
- 我的购机(手机)之路
- 想学习Python,这套教程再适合你不过了!
- 下一代数据备份方式会是DNA吗?
- Linux kill 多余用户终端
- 五分钟了解机器学习的基本概念
- python可以做什么灰产-广州市标书资料销毁详细流程
- 《UnityAPI.RenderTexture渲染纹理》(Yanlz+Unity+SteamVR+云技术+5G+AI+VR云游戏+RenderTexture+isCubemap+立钻哥哥++OK++)
- 成都生物研究所高性能计算服务器,专家人才库数据----中科院成都生物所资源库...
- Kali实现ARP欺骗
- 华为matepad切换电脑模式_华为matepadpro可不可以当电脑(华为matepadpro可以当电脑吗)...
- CV算法工程师面试问题集锦,从基础到进阶,会介绍细节,持续更新中......
- Jutoh 2.91 电子书设计制作软件
- Requests模拟登陆与代理设置
- 人工智能机器视觉专业英语积累
- thinkphp5,android混合开发基础恶补篇
热门文章
- matlab保存每次循环的结果
- 文献笔记5 review on RS Hydrology
- 编译ok6410linux内核,OK6410新手学习心得(一)Linux中加入led驱动及测试程序详解...
- 一个函数返回参数二进制中1的个数
- 为什么 30 岁的工程师容易跳槽?
- FFmpeg总结(六)AV系列结构体之AVPacket
- linux怎么安装网卡驱动固件,Linux网卡驱动的安装方式
- mysql server 6.0_MySQL Server 6.0完全卸载以及卸载中遇到的问题
- win7系统不能加入工作组计算机,技术员教你解决win7系统工作组计算机无法访问的修复办法...
- 新建test.c为什么没有.h文件_新建STM32工程全局声明两个宏的原因