Microwave Biscuit

I *heart* lsof

Posted in Linux, ubuntu by microwavebiscuit on November 12, 2008

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

Which returned:


amarokapp 20243 me 128r DIR 11,0 2048 1344 /media/cdrom0

There it is – exit amarok and the cd ejects.

About these ads

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

Follow

Get every new post delivered to your Inbox.

%d bloggers like this: