Lsof

lsof

Options

 * -a: combined by AND (default is OR)
 * +r/-r: If ‘+r’ is used then, the repeat mode will end when no open files are found. ‘-r’ will continue to list,delay,list until a interrupt is given; time in seconds
 * -i: list network files
 * -p: specific process id

Examples
List processes which opened a specific file lsof file List opened files under a directory lsof +D /var/log/ List files openned by a specific user lsof -u user Repeat mode lsof -u user_name -c init -a -r5 List all network files in use by a specific process lsof -i -a -p 234 List processes which are listening on a particular port lsof -i :25 List all TCP or UDP connections lsof -i tcp; lsof -i udp; lsof -i tcp -s TCP:ESTABLISHED lsof -i | grep ":[0-9]\+->" -o | grep "[0-9]\+" -o | sort | uniq