Use lsof to check which process open the specify file
Problem
Problem
Some times when we want to eject the usb disks, it will report that some process are using the disk, it can’t be eject, or want to delete a file, it will be failed to delete because some other processes are using it.
Solution
The solution to solve the problem is find which process is using the file or disk, we can use lsof
command to implement it.
Example
I have a file test.docx
and open it with word, than use the following command to check whether it was opened by other application.$ lsof test.docx
COMMAND PID USER FD TYPE DEVICE SIZE/OFF NODE NAME
Microsoft 33024 Stephen 58u REG 1,9 12055 149608590 test.docx