在用戶登陸的時候執行sh腳本的順序:每次登陸的時候都會徹底執行的
/etc/profile.d/file
/etc/profile
/etc/bashrc
/root/.bashrc
/root/.bash_profile
因此若是你想覆蓋的話你也就知道了怎麼去覆蓋linux
若是想弄明白以上的問題,嘗試着去讀man bash這是最直觀的說明了。shell
名詞理解:bash
A login shell is one whose first character of argument zero is a -, or one started with the –login option.this
交互式login shell的狀況以下:
When bash is invoked as an interactive login shell, or as a non-interactive shell with the –login option, it first reads and executes commands from the file /etc/profile, if that file exists. After reading that file, it looks for ~/.bash_profile, ~/.bash_login, and ~/.profile, in that order, and reads and executes commands from the first one that exists and is readable. The –noprofile option may be used when the shell is started to inhibit this behavior.(使用–noprofile選項激活Bash能夠禁止其讀任何初始化文件)
When a login shell exits, bash reads and executes commands from the files ~/.bash_logout and /etc/bash.bash_logout, if the files exists.
交互式 non login shell狀況以下:
When an interactive shell that is not a login shell is started, bash reads and executes commands from ~/.bashrc, if that file exists. This may be inhibited by using the –norc option. The –rcfile file option will force bash to read and execute commands from file instead of ~/.bashrc.線程
非交互式
當運行shell腳本時,bash是非交互式的
在interactive shell下執行腳本,將會啓動non-interactive shell, non-interactive shell從其父進程處繼承環境變量繼承
環境變量用戶變量永久變量臨時變量(這些概念這的很亂)
env
export
set
unset進程
若是可以搞清楚這些東西,也就清楚了linux的變量是從哪裏來的了,也就明白了,shell變量不過如此,並且也明白了shell變量和linux內核真的是相距甚遠。咱們最容易犯的錯誤就是所見即所得,咱們老是覺得bash是linux,其實否則,bash只是一層殼,而真正的linux內核的各類資源分配,線程調度纔是linux內核。資源
問題:當咱們輸入一個命令時,linux是怎麼去解析的?
我想會去搜索這個命令並執行這個命令。it