https://shreevatsa.wordpress.com/2008/03/30/zshbash-startup-files-loading-order-bashrc-zshrc-etc/
linux系統里有各種啟動加載文件:
.bashrc、.bash_profile、.bash_login、.profile 等,事實上,這里的文件並不是都會被用到,這取決於是以何種方式進入系統
對bash,讀取順序如下表所示,先執行A,然后B,然后C , B1,B2,B3的意思是,按順序讀取最先讀到的一個。
| Interactive login | Interactive non-login | Script | |
|---|---|---|---|
| /etc/profile | A | ||
| /etc/bash.bashrc | A | ||
| ~/.bashrc | B | ||
| ~/.bash_profile | B1 | ||
| ~/.bash_login | B2 | ||
| ~/.profile | B3 | ||
| BASH_ENV | A | ||
| ~/.bash_logout | C |
從tty登錄和通過ssh遠程登錄,就是 login shell
以 docker exec -it container bash 方式進入容器的,輸入 non-login 的 shell
