bash配置文件
阿新 • • 發佈:2018-05-30
bash alias 環境變量 bash配置文件
全局:/etc/bashrc
用戶:~/.bashrc
登錄式shell 與 非登錄式shell
按生效範圍劃分:
全局配置文件:/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提供配置 用於定義命名別名,本地變量
用戶:~/.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配置文件