Skip to content

Commit

Permalink
doc: Update lsof.md #577
Browse files Browse the repository at this point in the history
  • Loading branch information
jaywcjlove authored May 8, 2024
1 parent 9b2d0a2 commit fe5f89b
Showing 1 changed file with 92 additions and 0 deletions.
92 changes: 92 additions & 0 deletions command/lsof.md
Original file line number Diff line number Diff line change
Expand Up @@ -156,8 +156,100 @@ lsof -i:9981 -P -t -sTCP:LISTEN
```shell
lsof $filename
```

查看端口占用
```shell
lsof -i:$port
```

**查看所有打开的文件:**

```
lsof
```

**查看指定进程打开的文件:**

```
lsof -p <PID>
```

**查看指定用户打开的文件:**

```
lsof -u <username>
```

**查看指定文件名相关的进程:**

```
lsof <filename>
```

**查看网络连接相关的进程:**

```
lsof -i
```

**查看指定端口相关的进程:**

```
lsof -i :<port>
```

**查看正在使用某个目录的进程:**

```
lsof +D /path/to/directory
```

**查看被删除但仍然被某个进程打开的文件:**

```
lsof -u +L1
```

**查看某个文件系统上被打开的文件:**

```
lsof /mountpoint
```

**以列表形式显示结果:**

```
lsof -F
```

**显示结果中不包含主机名:**

```
lsof -n
```

**显示结果中不包含进程路径:**

```
lsof -b
```

**以逆序显示结果:**

```
lsof -r
```

**以特定间隔时间循环显示结果:**

```
lsof -r <interval>
```

**以持续模式显示结果:**

```
lsof -t <interval>
```


0 comments on commit fe5f89b

Please sign in to comment.