http://www.linuxplanet.com/linuxplanet/tips/6721/1
Linux Process Management: Using lsof to List Open Fileslsof Reveals AllApril 9, 2009
lsof (no options) will list all files opened by any processes currently running. To restrict this to processes owned by username, uselsof -u username. Here's some sample output: lsof filename shows which processes have files of this name open. lsof +D /directory will show processes which have files in this directory open. You can use this if you're trying to unmount a filesystem but getting an 'in use' error, to find the processes using files on that FS and kill them as required. lsof -c processname will show all processes beginning with processname that have files open; lsof +p PID does the same thing for a process ID. Using lsof -i will get you information about IP sockets. Check out the man page for more detail and for the many other available options. Article courtesy of ServerWatch |