在 Linux 中如何找出哪个进程锁定了某个文件?

发布于 2024-07-11 21:41:47 字数 74 浏览 5 评论 0原文

今天我遇到了无法删除文件夹的问题,因为“它很忙”。

我怎样才能找出应该归咎于哪个应用程序,或者我可以用暴力删除它?

Today I had the problem that I couldn't delete a folder because "it was busy".

How can I find out which application to blame for that or can I just delete it with brute force?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(4

薯片软お妹 2024-07-18 21:41:47

使用 lsof 找出哪些文件已打开。

man lsof 或看看这里

Use lsof to find out what has what files are open.

man lsof or have a look here

梦萦几度 2024-07-18 21:41:47

fuser Unix 命令将为您提供进程访问文件。

The fuser Unix command will give you the PIDs of the processes accessing a file.

将军与妓 2024-07-18 21:41:47

lslocks 列出了 Linux 系统中当前持有的所有文件锁的信息。 (util-linux 的一部分)该实用程序支持 json 输出,这对于脚本来说非常有用。

~$ sudo lslocks
COMMAND           PID   TYPE SIZE MODE  M START END PATH
cron              873  FLOCK   4B WRITE 0     0   0 /run/crond.pid

..
..

lslocks lists information about all the currently held file locks in a Linux system. (part of util-linux) this utility has support for json output, which is nice for scripts.

~$ sudo lslocks
COMMAND           PID   TYPE SIZE MODE  M START END PATH
cron              873  FLOCK   4B WRITE 0     0   0 /run/crond.pid

..
..

南城追梦 2024-07-18 21:41:47

fuser 将显示哪些进程正在访问文件或目录。

fuser will show you which processes are accessing a file or directory.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文