Tales From The Command Line: What’s Going On? (lsof)

August 1, 2008 · Print This Article


As mentioned in the previous installment, there is a very useful command buried deep within the confines of your OS X terminal. that command - lsof (LiSt Open Files) - is like the Swiss Army knife of utilities, proving data on files, directories, volumes and even what is happening on the network. Unlike iftop, lsof does not require any downloads. Simply open up a Terminal.app session and enter: lsof.

Give that command a minute to run and prepare to be overwhelmed with info in a cryptic, textual, tabular format. The command, used in that way, is actually pretty useless (from an interactive standpoint). Its true capability becomes unleashed with the proper command-line options, execution privileges and when grouped with some other command-line-fu. After the small primer in that post, you should be well equipped to figure out what applications are talking on the network, what files your applications have open and what is keeping your volumes from being able to be ejected.

Before we start, it may be a bit confusing when a utility that claims to list open files can supply

knowledge on network traffic. You have to remember that in OS X (UNIX-like systems in general) an open file may be a regular file, a directory, a block special (enables communication with device drivers) file, a character special (facilitates communication with a device one character at a time) file, a library, a stream or a network file (i.e. a network connection).

The examples in that post plus produce heavy use of CLIX (Command Line Interface for OS *X*). As you’ll see, lsof output can be a bit much for those just getting started with Terminal.app and CLIX provides a nice wrapper around the OS X command line utilities and allows you to keep similar commands organized with a much friendlier output window than the Terminal. It comes with an amazing set of pre-built command libraries that are well worth the moment to go through. You will come away with a great education on the innards of OS X.
(more…)

Orginal post by Bob Rudis

Submit yourself for as many Auditions as you want for FREE

Comments

Got something to say?

You must be logged in to post a comment.