List Open Files


lsof

Chapter 1, "Things to Know About Your Command Line," discussed the fact that everything is a file to a Linux machine, including directories, network connections, and devices. That means that even though from your perspective you only have one file opena letter to your Momyour system actually has thousands of files open at any one time. That's rightthousands. To see the complete list of those open files, use the lsof command (short for list open files).

Actually, don't. If you just run lsof by itself (to get the full list of results, you need to be root), you'll receive as output that list of thousands of files. On this system, there were 5,497 files open and being used. Still, lsof can be a useful way to get an idea of just how much is going on with your computer at any one time.

Piping the output of lsof to less gives you the results one screen at a time.

# lsof | less COMMAND PID USER FD TYPE DEVICE SIZE NODE NAME init      1 root cwd DIR 3,1     656    2 / init      1 root rtd DIR 3,1     656    2 / init      1 root txt REG 3,1   31608 2072 /sbin/init 


Still, with 5,497 results, that's many screens to page through. You can also pipe the output of lsof to grep. As you'll see in the next few sections, however, lsof contains within itself ways to filter out the data you don't want to see so you can focus only on a particular subset of open files that interest you.



Linux Phrasebook
Linux Phrasebook
ISBN: 0672328380
EAN: 2147483647
Year: 2007
Pages: 288

flylib.com © 2008-2017.
If you may any questions please contact us: flylib@qtcs.net