Swiss Army Knife of Unix Debugging: lsof
catonmat.net
catonmat.net
lsof doesn't really do anything for you if you know the pid already. (But it's great if you don't know the pid.)
Then, look through the list for your file, and copy the file descriptor just like in the article.
DTrace fits that description much closer, even though its only available for OpenSolaris, OS X, I believe FreBSD has a port and Linux is getting one.
edit: also see: strace, ltrace, gdb, truss
Linux does indeed have a port of dtrace, but it's not legal due to Sun's license.
Gonna write about strace in one of the next articles. And possibly also about dtrace in another article.
It's nice to have a hardbound copy of the newest edition, but the previous edition is available for comparatively cheap (US$6), and torrents of both seem to get around. FYI.
I will now have all three books, reasoned, seasoned and little schemer. :)
Huge thanks to the person who bought the reasoned schemer!
Merry Christmas!
http://linuxcommand.org/man_pages/fuser1.html
It's really handy for some situations. For instance, if a process can't grab some port, you can use fuser to quickly determine which process grabbed it first.
Port is in use 8003.
lsof -i :8003
Then I kill whatever process was on 8003. I do this a lot with my Django development if I didn't kill the server right the first time.