. DOT and Subshell
. (dot) runs a shell script in the current environment and then returns. Normally, the shell runs a command file in a subshell so that changes to the environment by such commands as cd, set, and trap are local to the command file. The . (dot) command circumvents
this feature.
A subshell does not inherit the environment variables from parent process.
Fork - system call
fork() creates a new process by duplicating the calling process. The new process, referred to as the child, is an exact duplicate of the calling process. However, child process has its own process id.
&
The Bash & (ampersand) is a builtin control operator used to fork processes. From the Bash man page, "If a command is terminated by the control operator &, the shell executes the command in the background in a subshell".
$BASHPID
Process ID of the current instance of Bash. This is not the same as the $$ variable, but it often gives the same result.
[oracle@odilab ~]$ echo $BASHPID
2540
$BASH_VERSION
The version of Bash installed on the system
[oracle@odilab ~]$ echo $BASH_VERSION
4.1.2(1)-release
Bash快捷键:
CTRL + R
查找历史命令。输入要查找的命令,ctrl + r 返回最近一个命令。再按ctrl + r 查看其他的。
CTRL + W
输入命令时,删除一个单词
CTRL + U
输入命令时,删除当前整条命令
CTRL + A
光标跑到行首。相当于"Home"键。
cd -
进入上一次的工作目录
本文介绍了Bash中的几个关键概念,包括使用.(dot)命令在当前环境中运行脚本、子shell的特点、fork系统调用创建进程的过程、&操作符用于后台运行进程的方法,以及一些实用的Bash快捷键。
503

被折叠的 条评论
为什么被折叠?



