From 444f0d850c08cd32762278af8007fe0377503c22 Mon Sep 17 00:00:00 2001 From: jaywcjlove <398188662@qq.com> Date: Sun, 30 Oct 2022 03:10:42 +0800 Subject: [PATCH] feat: update `lsof.md` cheatsheet. --- docs/lsof.md | 43 ++++++++++++++++++++++++------------------- 1 file changed, 24 insertions(+), 19 deletions(-) diff --git a/docs/lsof.md b/docs/lsof.md index fbfe00b..6c90176 100644 --- a/docs/lsof.md +++ b/docs/lsof.md @@ -80,6 +80,7 @@ $ kill -9 $(lsof -t -i :8080) ### 参数 + ```bash -a # 列出打开文件存在的进程; @@ -96,6 +97,28 @@ $ kill -9 $(lsof -t -i :8080) -v # 显示版本信息 ``` +### 列出指定进程号所打开的文件 + +```bash +lsof -p $pid +``` + +### 获取端口对应的进程 ID=>pid + +```bash +lsof -i:9981 -P -t -sTCP:LISTEN +``` + +### 列出打开文件的进程: + +```bash +lsof $filename +``` + + +示例 +--- + ### 示例 @@ -117,7 +140,7 @@ migration 2 root txt unknown /proc/2/exe ``` ### 文件描述符列表(FD) - + :- | :- :- | :- @@ -195,21 +218,3 @@ migration 2 root txt unknown /proc/2/exe `NODE` | 索引节点(文件在磁盘上的标识) `NAME` | 打开文件的确切名称 `REG` | 常规文件 - -### 列出指定进程号所打开的文件 - -```bash -lsof -p $pid -``` - -### 获取端口对应的进程 ID=>pid - -```bash -lsof -i:9981 -P -t -sTCP:LISTEN -``` - -### 列出打开文件的进程: - -```bash -lsof $filename -``` \ No newline at end of file