docs:unix:lsof

lsof

list open files

  • 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)
lsof -c QuickTime
  • you can replace sort | uniq with “sort -u”
lsof | grep ' root ' | awk '{print $NF}' | sort | uniq | wc -l
179
  • docs/unix/lsof.txt
  • Last modified: 2013/05/09 11:46
  • by billh