Live data from Hacker News

A Unix Utility to Know About: lsof (2009)

catonmat.net

1–10 of 54 posts

Re: A Unix Utility to Know About: lsof (2009)

#3
post #2

`lsof` and `ps` have the most dense man pages I have ever tried to plow through, and that's causing me to use these tools only at a minimum.

Sometimes powerful tools require effort to understand. Lsof is absolutely something you should spend some real time grokking.

In regard to ps you can memorize a few commands until something truly weird comes up since you will probably use other more specialized snapshotting and tracing tools for anything somewhat difficult to troubleshoot.

Re: A Unix Utility to Know About: lsof (2009)

#5
For finding what uses a file, I'm an 'fuser' kid but lsof is fine too. Using posh right now, so had to make my own:

    function fuser($relativeFile){
      $file = Resolve-Path $relativeFile
      foreach ( $Process in (Get-Process)) {
        foreach ( $Module in $Process.Modules) {
          if ( $Module.FileName -like "$file*" ) {
            $Process | select id, path
          }
        }
      }
    }
In use:

    > fuser .\node_modules\

      Id Path
      -- ----
    2660 C:\Program Files\nodejs\node.exe
Since it's object pipelining, you can:

    > fuser .\node_modules\ | kill

Re: A Unix Utility to Know About: lsof (2009)

#6
post #2

`lsof` and `ps` have the most dense man pages I have ever tried to plow through, and that's causing me to use these tools only at a minimum.

Sometimes powerful tools require effort to understand. Lsof is absolutely something you should spend some real time grokking. In regard to ps you can memorize a few commands until something truly weird comes up since you will probably use other more specialized snapshotting and tracing tools for anything somewhat difficult to troubleshoot.

> Sometimes powerful tools require effort to understand. Lsof is absolutely something you should spend some real time grokking.

Yup, this is true. And I did. But sometimes you just need less dense manual pages.

Re: A Unix Utility to Know About: lsof (2009)

#7
post #2

`lsof` and `ps` have the most dense man pages I have ever tried to plow through, and that's causing me to use these tools only at a minimum.

I am guilty of using `ps|aux` for the sole purpose of answering this question: Is it (still) running ?

edit: `ps aux|grep`, indeed. Silly me in the early hours of a rest day :).

Re: A Unix Utility to Know About: lsof (2009)

#9
post #2

`lsof` and `ps` have the most dense man pages I have ever tried to plow through, and that's causing me to use these tools only at a minimum.

Sometimes powerful tools require effort to understand. Lsof is absolutely something you should spend some real time grokking. In regard to ps you can memorize a few commands until something truly weird comes up since you will probably use other more specialized snapshotting and tracing tools for anything somewhat difficult to troubleshoot.

I find lsof and ps too hard to remember, so I usually just use regular linux utilities like cat/grep on the /proc file system.

  - grep bash /proc/*/status
  - readlink /proc/*/fd/* | grep /run

Re: A Unix Utility to Know About: lsof (2009)

#10
post #2

`lsof` and `ps` have the most dense man pages I have ever tried to plow through, and that's causing me to use these tools only at a minimum.

I am guilty of using `ps|aux` for the sole purpose of answering this question: Is it (still) running ? edit: `ps aux|grep`, indeed. Silly me in the early hours of a rest day :).

You mean `ps aux | grep` which I am also guilty of using every time ? You might be interested in pgrep (http://linux.die.net/man/1/pgrep) as well.
Post reply on HN