FrankKai.github.io
FrankKai.github.io copied to clipboard
一些Linux知识点
也可以叫操作系统知识点。
- Controlling Terminal
- recent CPU usage与elapsed CPU usage
- kill 与 kill -9之间的区别是什么?
- bash是什么东西?
Controlling Terminal
起源于学习ps -ef
,-e参数等同于-A,-A,Display information about other users' processes, including those without controlling terminals.
- 进程的一个属性之一就是 controlling terminal。
- 通过fork创建的子进程继承来自他们父进程的controlling terminal。
- 所有在一个session钟的继承了session leader的controlling terminal。
- 拥有一个terminal的控制权的session leader,称作controlling process(控制进程)。
- 无需关注向一个session分配一个controlling terminal的原理,因为登录系统时就已经处理好了。
- 独立的进程通过
setsid
与controlling terminal断开连接,成为一个新session的leader。
recent CPU usage与elapsed CPU usage
起源于学习ps -ef
, -f,Display the uid, pid, parent pid, recent CPU usage, process start time, controlling tty, elapsed CPU usage, and the associated command.
501 27289 1 0 五09上午 ?? 116:35.74 /Applications/WebStorm.app/Contents/MacOS/webstorm
501 72045 71609 0 10:39上午 ttys003 0:00.00 grep webstorm
elapsed CPU usage 为116:35.74, 0:00.00。
kill 与 kill -9之间的区别是什么?
起源于学习kill -9
,-9这个参数的描述信息是:non-catchable, non-ignorable kill。
- kill发送SIGTERM中止自己,释放内存,照顾其他子进程,gracefully die。
- kill -9 发送SIGKILL,不是gracefully die,不会检查进程的状态,立即杀掉进程。
non-catchable, non-ignorable的区别是什么?
- kill生成的SIGTERM指令,会在进程处于safe state(清理内存或者相同的操作)时,命令被忽略,导致进程kill失败。
- 但是由kill -9 生成的SIGKILL指令,完全不会考虑进程的状态,可能会导致问题但是一定会立即关闭。
kill -9暴力杀进程,不会缓存,不会被忽略,不care进程状态。
bash是什么东西?
前置知识
之前用windows系统时,会用到git的bash。
自定义的环境变量,会保存在.bash_profile中。
docker中运行ubuntu镜像时,会在最后指定一个bash:docker run -t -i ubuntu bash
bash是什么东西?
man bash
bash - GNU Bourne-Again SHell
Bash is an sh-compatible command language interpreter that executes commands read from the standard input or from a file. Bash also incor-porates useful features from the Korn and C shells (ksh and csh).Bash is intended to be a conformant implementation of the Shell and Utilities portion of the IEEE POSIX specification (IEEE Standard 1003.1). Bash can be configured to be POSIX-conformant by default.
- Bash是一个sh-compatible的命令语言解释器。
- Bash可以通过标准输入或者文件读取到命令。
- Bash同样包含了Korn(ksh)和C shell(csh)的有用特性。
- Bash目的成为IEEE POSIX规范的Shell和实用程序部分的一致实现。
- 默认情况下的Bash是posix一致的。
GNU是什么?
GNU is a recursive acronym for "GNU's Not Unix!",[11][14] chosen because GNU's design is Unix-like, but differs from Unix by being free software and containing no Unix code.