> For the complete documentation index, see [llms.txt](https://shuixn.gitbook.io/notebook/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://shuixn.gitbook.io/notebook/xing-neng-fen-xi/jin-cheng-guan-li.md).

# 进程管理

进程是资源分配的最小单元，线程是任务调度执行的最小单元

## 常用命令

1. ps: 获取某个时间点的进程运行情况，常用参数：ef，aux
2. pstree：寻找进程之间的相关性（-A）；查询PID与所属用户（加上-p和-u）
3. nice：用于设置和改变进程的优先级，范围-20\~19，值越低，优先级越高
4. renice：改变正在运行的进程优先级，只能改变他们自己的进程的优先级
5. kill：强制杀进程（-9）+进程ID。pkill类似，使用模式匹配，如进程名，进程拥有者
6. fg,bg：将任务调到前台或后台执行。还可以通过在命令后面加’&’放在后台执行。jobs命令列出所有后台进程
7. lsof：查看进程打开的文件
