【.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 文件中。因为不管是登陆还是不登陆,该文件总会被调用!

最新文章

  1. Android Token的使用学习
  2. mac os x 安装mysql遇到 Access denied for user 'root'@'localhost' (using password: YES)的解决方法
  3. Mac上git的安装配置与使用简述
  4. PHP Code Reviewing Learning
  5. read 隐藏用户输入
  6. 【原】在一般处理程序中设置session
  7. 成功在BAE上部署ghost 5.0
  8. 2016届百度实习生前端笔试题上海卷a
  9. Linux下Qt4与qt5的程序使用输入法(ibus与fcitx)不冲突
  10. Abp异常-找不到方法:“System.String Abp.Runtime.Security.SimpleStringCipher.Decrypt(System.String, System.String, Byte[])”
  11. ASP.NET Core 认证与授权[7]:动态授权
  12. windows下cmd常用
  13. Knowledge point
  14. Nginx的编译安装及选项
  15. 【MyBatis-Spring】Mybatis和并入Spring框架
  16. winserver 2008 R2服务器安装IIS
  17. vue中$mount与el区别
  18. 《精通Python网络爬虫》
  19. 如何利用VMware安装XP系统
  20. Centos的升级与更新

热门文章

  1. 使用Vue前端框架实现知乎日报app
  2. java8 stream初试,map排序,list去重,统计重复元素个数,获取map的key集合和value集合
  3. 对AC自动机+DP题的一些汇总与一丝总结 (1)
  4. async await task.Result 卡死
  5. 使用MingGW-w64 Build Script 3.6.7搭建ffmpeg编译环境
  6. mysql执行拉链表操作
  7. Linux_IPtables防火墙详解
  8. laravel 5.6 使用RabbitMQ作为消息中间件
  9. linux 进程间共享内存示例
  10. IntelliJ IDEA 配置 Hadoop 源码阅读环境