Introduction to lsof

The lsof package is useful to LiSt Open Files for a given running application or process.



Development versions of BLFS may not build or run some packages properly if dependencies have been updated since the most recent stable versions of the book.

Package Information

lsof Dependencies




Nmap-7.92 (with a symbolic link nc pointing to ncat in /usr/bin; used in tests)

User Notes:

Kernel Configuration

To run the tests, the following option should be enabled in the kernel configuration:

General setup  --->
  [*] POSIX Message Queues    [CONFIG_POSIX_MQUEUE]

Installation of lsof

Install lsof by running the following commands:

./Configure -n linux &&

The tests should be run as the root user. They require that the POSIX message queues are enabled in the kernel, and that Nmap-7.92 be installed with a symbolic link /usr/bin/nc pointing to ncat.

make check

One test, case-20-ux-socket-endpoint, is known to fail. Other test may fail if the tests are run in a script.

Now, as the root user:

install -v -m4755 -o root -g root lsof /usr/bin &&
install -v lsof.8 /usr/share/man/man8

Command Explanations

./Configure -n linux: Avoid AFS, customization, and inventory checks, and use the linux dialect.

install -m4755 ...: lsof should be suid root to allow users to list all files. This may be a security threat on some systems. In that case change to -m755 and use sudo to run the program.


Installed Program: lsof
Installed Libraries: None
Installed Directories: None

Short Descriptions


lists open files for running processes