码迷,mamicode.com
首页 > 系统相关 > 详细

【Linux】常用命令 lsof查看打开的文件

时间:2015-09-06 23:02:18      阅读:312      评论:0      收藏:0      [点我收藏+]

标签:

Linux系统把软硬件都抽象成文件,所以通过文件可以追踪到很多重要信息,如读取的配置文件、打开的端口等。

下面是常见的用法:

默认测试文件名为text.txt

1,显示打开text.txt的进程:

lsof text.txt

2,显示占用某个端口的进程:

lsof -i :80

3,显示某个进程(进程名)打开的文件:

lsof -c process_name

4,显示某个进程号(pid)打开的文件:

lsof -p pid_number

5,显示某个用户打开的文件:

lsof -u user_name

默认输出字段解释:

[groot]$lsof -u groot
COMMAND PID USER FD TYPE DEVICE SIZE/OFF NODE NAME

COMMAND:进程名字(默认下只取前9个字符);

PID:Process IDentification number;

USER:the user ID number or login name of the user to whom the process belongs;

FD:File Descriptor number or

  cwd current working directory;

  ltx   shared library text(code and data);

  mem memory-mapped file;

  mmap memory-mapped device;

  pd   parent directory;

  rtd   root directory;

  txt   program text(code and data);

TYPE:is the type of the node associated with the file - e.g., GDIR, GREG, VDIR, VREG, etc.

 

【Linux】常用命令 lsof查看打开的文件

标签:

原文地址:http://www.cnblogs.com/buffalo/p/4787550.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!