====== lsof ====== ===== Description ===== list open files ===== Example: Which ports are open? ===== * Updated, better example lsof -i TCP * Older example # lsof | grep TCP portmap 2587 rpc 4u IPv4 5544 TCP *:sunrpc (LISTEN) rpc.statd 2606 root 6u IPv4 5585 TCP *:668 (LISTEN) sshd 2788 root 3u IPv6 5991 TCP *:ssh (LISTEN) sendmail 2843 root 4u IPv4 6160 TCP badhd:smtp (LISTEN) vsftpd 9337 root 3u IPv4 34949 TCP *:ftp (LISTEN) cupsd 16459 root 0u IPv4 41061 TCP badhd:ipp (LISTEN) sshd 16892 root 3u IPv6 61003 TCP badhd.mshome.net:ssh->kontiki.mshome.net:4661 (ESTABLISHED) ===== Example: Show files open by Quicktime ===== lsof -c QuickTime ===== Example: Show files open by a user ===== * you can replace sort | uniq with "sort -u" lsof | grep ' root ' | awk '{print $NF}' | sort | uniq | wc -l 179