首页 > 其他 > 详细

bash配置文件

时间:2018-05-29 22:46:53      阅读:259      评论:0      收藏:0      [点我收藏+]
技术分享图片bash配置文件

按生效范围划分:
全局配置文件:/etc/profile 调用 /etc/profile.d/*.sh

/etc/profile.d/*.sh

用户配置文件: ~/.bash_profile  调用      ~/.bashrc

~/.bash_profile 一般配置用户环境变量
~/.bashrc 一般配置用户别名

按功能划分:
profile 类:为交互式登录的shell 提供配置 用于定义环境变量,运行命令和脚本
全局:/etc/profile /etc/profile.d/*.sh
用户:~/.bash_profile
bashrc类: 为非交互式登录的shell提供配置 用于定义命名别名,本地变量
全局:/etc/bashrc
用户:~/.bashrc
登录式shell 与 非登录式shell

登录式shell       需要用户名密码输入
             登录图型化
              登录文本tty终端
              远程登录如ssh,telnet
              su - 

执行顺序:/etc/profile --> /etc/profile.d/*.sh --> ~/.bash_profile --> ~/.bashrc --> /etc/bashrc

非登录式      不需要用户名密码输入
            su  
            执行shell脚本
            在已登录的图型介面打开终端 

执行顺序:~/.bashrc --> /etc/bashrc --> /etc/profile.d/*.sh

通过编辑修改的配置文件生效方式:

  • 1、退出并重新登陆
  • 2、让bash 重读此配置文件
    source 和 . 在当前shell下执行来自文件的命令。
    使用脚本执行 是在子shell下执行命令,那么父shell是无法继承来自脚本中的变量

bash配置文件

原文:http://blog.51cto.com/12288447/2121759

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