--- id: 0e4f5039-4c89-4465-a8bb-116ac188dd1b slug: linux-process-learning-1 title: Linux 进程学习 一 summary: "" status: published tags: [] cover: "" version: 1 slug_source: manual slug_locked: true published_at: "2022-10-16T15:54:11+08:00" created_at: "2022-10-16T15:54:11+08:00" updated_at: "2026-01-07T18:10:40+08:00" --- ## 什么是进程? 在了解进程的时候,首先得知道什么是程序。 操作系统其实学过,程序被执行时,操作系统将可执行文件复制到内存中,这就是程序,而进程则是程序的实例,是系统资源分配的基本单位,它被唯一标识于 PCB 之中,也就是进程控制块。 ## ps 命令 查看进程 >Note that ps -aux is distinct from ps aux. The POSIX and UNIX standards require that ps -aux print all processes owned by a user named x, as well as printing all processes that would be selected by the -a option. If the user named x does not exist, this ps may interpret the command as ps aux instead and print a warning. This behavior is intended to aid in transitioning old scripts and habits. It is fragile, subject to change, and thus should not be relied upon. >To see every process on the system using BSD syntax: ps ax ps axu 也就是说,我们可以通过 **ps axu** 来查看系统中的进程 ## top 命令 查看进程 > The top program provides a dynamic real-time view of a running system. 这个命令显示的进程状态是动态更新的。 以下是常用命令: - q:退出top命令 - :立即刷新 - s:设置刷新时间间隔 - t:显示或隐藏进程和CPU状态信息 - m:显示或隐藏内存状态信息 - P:按%CPU使用率排行 - M:按%MEM排行 - u:指定显示用户进程 - k:kill进程 - i:只显示正在运行的进程 - h:帮助命令。