Skip to content

Programs and processes

Linux & the command line Lesson 13 2:04 English narration · English + 中文 subtitles burned in

space play · ←/→ 5s · j/l 10s · f fullscreen · ,/. speed

Chapters

Transcript
Two words that sound the same and are not. 有两个词听起来差不多,其实不一样。
A program is a file sitting on disk, doing nothing. 程序是一个躺在磁盘上、什么也没做的文件。
A process is that file running — your browser, your editor, and the shell you are typing into are all processes. 进程是那个文件正在运行—— 你的浏览器、你的编辑器、还有你正在敲字的这个 shell,都是进程。
Open the same editor twice and you get two processes from one program, with different PIDs. 把同一个编辑器打开两次,你就得到了来自一个程序的两个进程,PID 各不相同。
Ps lists what is running. ps 列出正在运行的东西。
Two columns matter here. 这里有两列要紧。
PID is the number the system uses for that process — you will need it in a moment. PID 是系统用来指代那个进程的数字——过一会儿你会需要它。
And percent CPU is how much of the processor it is taking. 而 %CPU 是它占用了多少处理器。
Look down that column and one of them stands out: ninety-eight percent, on something called render, while everything else sits near zero. 顺着那一列往下看,有一个特别扎眼: 98%,在一个叫 render 的东西上,而其他所有的都接近零。
And here is something worth noticing about this whole course. 这里有一件值得注意的、关于整门课的事。
A process list is just lines of text, so grep finds the line you want and w c counts them — the same two commands you used on a poem in lesson three. 一份进程列表就是一些文本行, 所以 grep 能找出你要的那一行,wc 能数它们—— 和你在第 3 课里用在一首诗上的是同样两条命令。
That is why the tasks below work on a saved snapshot: the skill is identical. 这也是为什么下面的题目是在一份保存好的快照上做的:技能是完全一样的。
Two ways to stop something. 有两种停止的方式。
Control C stops the program running in front of you, in this terminal, right now. Ctrl-C 停掉此刻在你面前、在这个终端里运行的那个程序。
For anything else, find its PID and use kill, which politely asks that process to stop and let it tidy up first. 对于别的,找到它的 PID,然后用 kill, 它会礼貌地请那个进程停下,并让它先收拾一下。
Kill dash nine forces it and gives it no chance to save anything, so it is a last resort, not a first move. kill -9 是强制的,不给它任何保存的机会, 所以那是最后手段,不是第一步。
Four things to take with you. 带走四点。
One: a process is a running program. 第一:进程是正在运行的程序。
Two: every process has a PID, its number. 第二:每个进程都有一个 PID,也就是它的编号。
Three: ps lists them and top shows a live view. 第三:ps 把它们列出来,top 显示一个实时的视图。
Four: control C stops the one in front of you, and kill takes a PID. 第四:Ctrl-C 停掉你面前那个,而 kill 要一个 PID。
Now do the tasks below on the saved snapshot. 现在在那份保存好的快照上做下面的题。

Log in or create account

IGCSE, A-Level & AP