首页 > 系统服务 > 详细

Linux中.bash_profile 加载

时间:2020-02-21 12:45:55      阅读:60      评论:0      收藏:0      [点我收藏+]

转载:https://www.cnblogs.com/markleaf/p/7794528.html

1.Debian默认的shell是Bash,
  1.1 命令行 和 ssh 登录 ,首先读入 /etc/profile,这是对所有用户都有效的配置;然后依次寻找下面三个文件,这是针对当前用户的配置。
   ~/.bash_profile
   ~/.bash_login
   ~/.profile

需要注意的是,这三个文件只要有一个存在,就不再读入后面的文件了。比如,要是 ~/.bash_profile 存在,就不会再读入后面两个文件了。

  1.2 图形界面登录:只加载 /etc/prfile 和 ~/.profile。也就是说,~/.bash_profile 不管有没有,都不会运行。

2.用户进入操作系统图形界面以后,常常会再手动开启一个shell。这个shell就叫做 non-login shell,意思是它不同于登录时出现的那个shell,不读取/etc/profile和.profile等配置文件。

3.终端模拟器通常会有选项来指定是开 login shell 还是 non-login shell,比如 xfce4-terminal 可以在设置中修改。
 (deepin-terminal 改 ~/.config/deepin/deepin-terminal/config.conf ——>run_as_login_shell=true 也是)。

终上所述:

  1. 图形界面登录是 non-login 不运行 .bash_profile 。
  2. shell 和 ssh 登录打开 login shell ,会运行 .bash_profile。
  3. 图形界面登录,可以指定 终端模拟器 为 non-login 还是 login ,但这只是指定 终端模拟器 ,经我实测,和写到 .bashrc 效果一样,每次打开终端都会执行一次。
  4. 要只在图形界面登录时执行一次,应该写入 .profile,而不是 .bash_profile,或者在 .profile 增加一条 调用 .bash_profile。

Linux中.bash_profile 加载

原文:https://www.cnblogs.com/pu20065226/p/12340584.html

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!