PDA

View Full Version : lsof - list open files



Max
September 6th, 2009, 09:49 PM
lsof (List open files) is a very useful admin command
It will List open files and tell you what process and user has a file open.

Some useful examples with this command:

lsof +D /tmp
This will list the processes that have open files in /tmp directory.


lsof -c php
This command will list the files and processes opened by the php command.


lsof /dev/cdrom
Lists what files are open on CD (can be used for other devices)


lsof -i TCP:80
Shows open TCP files for port 80


lsof -u root
Will list all open files by user root


lsof -p PID
*Replace PID with a real PID, and it will lists all files open by that PID