gpt4 book ai didi

unix - unix 进程正在使用的文件

转载 作者:行者123 更新时间:2023-12-03 21:01:08 28 4
gpt4 key购买 nike

fuser 命令让我知道哪些进程正在使用文件或目录。

我正在寻找相反的命令:让我知道进程正在使用哪些文件。

更新

忘了说它是针对 Solaris 系统的。

最佳答案

lsof -p <pid>
来自 here

lsof stands for “LiSt Open Files”. This shell command seems deceptively simple: It lists information about files opened by processes on a UNIX box.

Despite its (apparent) modest mission statement, lsof is actually one of the most powerful and useful UNIX commands. Its raw power comes from one of UNIX’s design principle often described as ”in UNIX everything is a file”. What this means is that the lsof concept of an open file not only covers regular files but also the following:


  • 目录
  • 流或网络文件(例如,Internet 或 UNIX 域套接字和 NFS 文件)
  • native 库(例如,链接到进程的 .soor .dylibdynamic 库)
  • 块和字符特殊文件(例如,磁盘卷、外部硬盘驱动器、控制台或鼠标)
  • 管道

  • 等等,我在我的系统上找不到 lsof!

    lsof is such a popular tool that it has been ported to pretty much all UNIX dialects (Linux, Mac OS X, BSD, Solaris, and so on). If it is unavailable on your box, use your usual package management system to install it. You can find lsof packages for Solaris on Sun Freeware.

    关于unix - unix 进程正在使用的文件,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/301247/

    28 4 0
    Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
    广告合作:1813099741@qq.com 6ren.com