Category: tips
Tip: using lsof revisited
February 17th, 2009Editor's note: this tip was contributed by Jochen Heuer.
lsof is a powerful tool that lists open files running processes. We've featured lsof in the Gentoo Monthly Newsletter before, and an astute reader has written in with yet another way to use lsof.
This command finds open but deleted (unlinked) files:
# lsof +aL1 /filesystem
Let's see it in action!
First, we create a sample file to view:
# sleep 300 > /foo & [1] 2972
Next, delete the file:
# rm foo
Finally, look for the problem files:
# lsof +aL1 / COMMAND PID USER FD TYPE DEVICE SIZE NLINK NODE NAME sleep 2972 root 1w REG 9,0 0 0 25931 /foo (deleted)