I *heart* lsof
lsof is a command to list open files. I learned about its usefulness a long time ago while working on an AIX box for work. Today I found it useful for a fairly simplistic reason. I was browsing the web and all of a sudden my CD drive spun up. I couldn’t understand what was making it spin but I decided I was going to eject the CD that was in the drive. I got an error telling me that I couldn’t “unmount the drive” as a program was using it. I tried a number of ways to unmount it but it seemed locked. I’m sure I could have done it somehow but I was curious as to what had the disk locked up so I issued a lsof command:
lsof | grep cd
amarokapp 20243 me 128r DIR 11,0 2048 1344 /media/cdrom0
There it is – exit amarok and the cd ejects.