Skip to content

Commit fe5f89b

Browse files
authored
doc: Update lsof.md #577
1 parent 9b2d0a2 commit fe5f89b

File tree

1 file changed

+92
-0
lines changed

1 file changed

+92
-0
lines changed

command/lsof.md

Lines changed: 92 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -156,8 +156,100 @@ lsof -i:9981 -P -t -sTCP:LISTEN
156156
```shell
157157
lsof $filename
158158
```
159+
159160
查看端口占用
160161
```shell
161162
lsof -i:$port
162163
```
163164

165+
**查看所有打开的文件:**
166+
167+
```
168+
lsof
169+
```
170+
171+
**查看指定进程打开的文件:**
172+
173+
```
174+
lsof -p <PID>
175+
```
176+
177+
**查看指定用户打开的文件:**
178+
179+
```
180+
lsof -u <username>
181+
```
182+
183+
**查看指定文件名相关的进程:**
184+
185+
```
186+
lsof <filename>
187+
```
188+
189+
**查看网络连接相关的进程:**
190+
191+
```
192+
lsof -i
193+
```
194+
195+
**查看指定端口相关的进程:**
196+
197+
```
198+
lsof -i :<port>
199+
```
200+
201+
**查看正在使用某个目录的进程:**
202+
203+
```
204+
lsof +D /path/to/directory
205+
```
206+
207+
**查看被删除但仍然被某个进程打开的文件:**
208+
209+
```
210+
lsof -u +L1
211+
```
212+
213+
**查看某个文件系统上被打开的文件:**
214+
215+
```
216+
lsof /mountpoint
217+
```
218+
219+
**以列表形式显示结果:**
220+
221+
```
222+
lsof -F
223+
```
224+
225+
**显示结果中不包含主机名:**
226+
227+
```
228+
lsof -n
229+
```
230+
231+
**显示结果中不包含进程路径:**
232+
233+
```
234+
lsof -b
235+
```
236+
237+
**以逆序显示结果:**
238+
239+
```
240+
lsof -r
241+
```
242+
243+
**以特定间隔时间循环显示结果:**
244+
245+
```
246+
lsof -r <interval>
247+
```
248+
249+
**以持续模式显示结果:**
250+
251+
```
252+
lsof -t <interval>
253+
```
254+
255+

0 commit comments

Comments
 (0)