在用户登陆的时候执行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