0

使用“lsof”,我可以检查打开文件的列表,是否有任何命令或任何其他方式可以检测文件被访问的位置。“lsof”命令的输出如下:-

COMMAND     PID       USER   FD      TYPE             DEVICE  SIZE/OFF       NODE NAME

init          1        ???  cwd       ???                ???       ???        ??? /proc/1/cwd (readlink: Permission denied)

init          1        ???  exe       ???                ???       ???        ??? /proc/1/exe (readlink: Permission denied)

init          1        ??? root       ???                ???       ???        ??? /proc/1/root (readlink: Permission denied)

init          1        ???  FDS                                                   /proc/1/fd/ (opendir: Permission denied)

init          2        ???  cwd       ???                ???       ???        ??? /proc/2/cwd (readlink: Permission denied)

init          2        ???  exe       ???                ???       ???        ??? /proc/2/exe (readlink: Permission denied)

init          2        ??? root       ???                ???       ???        ??? /proc/2/root (readlink: Permission denied)

init          2        ???  FDS                                                   /proc/2/fd/ (opendir: Permission denied)

init          3        ???  cwd       ???                ???       ???        ??? /proc/3/cwd (readlink: Permission denied)

init          3        ???  exe       ???                ???       ???        ??? /proc/3/exe (readlink: Permission denied)

init          3        ??? root       ???                ???       ???        ??? /proc/3/root (readlink: Permission denied)

init          3        ???  FDS                                                   /proc/3/fd/ (opendir: Permission denied)

init          4        ???  cwd       ???                ???       ???        ??? /proc/4/cwd (readlink: Permission denied)

init          4        ???  exe       ???                ???       ???        ??? /proc/4/exe (readlink: Permission denied)

init          4        ??? root       ???                ???       ???        ??? /proc/4/root (readlink: Permission denied)

init          4        ???  FDS                                                   /proc/4/fd/ (opendir: Permission denied)

init          5        ???  cwd       ???                ???       ???        ??? /proc/5/cwd (readlink: Permission denied)

init          5        ???  exe       ???                ???       ???        ??? /proc/5/exe (readlink: Permission denied)

init          5        ??? root       ???                ???       ???        ??? /proc/5/root (readlink: Permission denied)

init          5        ???  FDS                                                   /proc/5/fd/ (opendir: Permission denied)

init          6        ???  cwd       ???                ???       ???        ??? /proc/6/cwd (readlink: Permission denied)

init          6        ???  exe       ???                ???       ???        ??? /proc/6/exe (readlink: Permission denied)

init          6        ??? root       ???                ???       ???        ??? /proc/6/root (readlink: Permission denied)

init          6        ???  FDS                                                   /proc/6/fd/ (opendir: Permission denied)

init          7        ???  cwd       ???                ???       ???        ??? /proc/7/cwd (readlink: Permission denied)

init          7        ???  exe       ???                ???       ???        ??? /proc/7/exe (readlink: Permission denied)

init          7        ??? root       ???                ???       ???        ??? /proc/7/root (readlink: Permission denied)

init          7        ???  FDS                                                   /proc/7/fd/ (opendir: Permission denied)

init          8        ???  cwd       ???                ???       ???        ??? /proc/8/cwd (readlink: Permission denied)

init          8        ???  exe       ???                ???       ???        ??? /proc/8/exe (readlink: Permission denied)

init          8        ??? root       ???                ???       ???        ??? /proc/8/root (readlink: Permission denied)

init          8        ???  FDS                                                   /proc/8/fd/ (opendir: Permission denied)

init          9        ???  cwd       ???                ???       ???        ??? /proc/9/cwd (readlink: Permission denied)

init          9        ???  exe       ???                ???       ???        ??? /proc/9/exe (readlink: Permission denied)

init          9        ??? root       ???                ???       ???        ??? /proc/9/root (readlink: Permission denied)

init          9        ???  FDS                                                   /proc/9/fd/ (opendir: Permission denied)

init         10        ???  cwd       ???                ???       ???        ??? /proc/10/cwd (readlink: Permission denied)

对于每个 pid,我得到三个位置,例如 pid "9",我得到以下位置:- "/proc/1/cwd (readlink: Permission denied)","/proc/9/exe","/proc/ 9/fd/ (opendir: 权限被拒绝)"

现在我怎么知道哪个文件正在被使用?我是新手,所以不太了解。任何建议都会对您有很大帮助。

4

1 回答 1

0

试试热熔器。http://linux.die.net/man/1/fuser 用于识别使用文件或套接字的进程。

于 2012-09-10T08:08:23.037 回答