[ Thanks to Jeremy Mack Wright for this
link. ]
“When you try to access an object on a Linux file
system that is in use, you may get an error telling you that the
device or resource you want is busy. When this happens, you may see
a message like the one in Listing 1.“Notice that there are 2 commands specified at the end of the
output – lsof and fuser, which are the two commands that this
post will be focused on.“Introducing lsof
“lsof is used to LiSt Open Files, hence the command’s
name. It’s a handy tool normally used to list the open files
on a system along with the associated processes or users, and can
also be used to gather information on your system’s network
connections. When run without options, lsof lists all open files
along with all of the active processes that have them open. To get
a full and accurate view of what files are open by what processes,
make sure that you run the lsof command with root privileges. To
use lsof on a specific file, you have to specify the full path to
the file. Remember that everything in Linux is a file, so you can
use lsof on anything from directories to devices. This makes lsof a
very powerful tool once you’ve learned it.”