$linuxjunkies
>

lsof

also: list open files

lsof (list open files) is a command-line utility that displays all open files and network connections associated with running processes on a system.

lsof shows detailed information about files currently opened by processes, including regular files, directories, device files, sockets, and pipes. This is useful for troubleshooting, monitoring, and understanding which resources a process is using.

The output includes columns for the process ID (PID), command name, user, file descriptor number, file type, and the file path or network address. For example, lsof -i :8080 reveals which process is listening on port 8080, while lsof -p 1234 lists all files opened by process ID 1234.

Common use cases include identifying which process holds a file lock, finding zombie processes, discovering open network sockets, and debugging why a filesystem cannot be unmounted. Root privileges are typically needed to see all processes and files on the system.

Related terms