Listing Open Files (lsof)
Concept & Overview
In Unix-like systems, "everything is a file." This means not only text files and folders, but also network sockets, system hardware, and processes are treated as files. To find out which files are being accessed by which running programs, we use lsof (List Open Files).
- Running lsof displays a comprehensive list of all open files, along with the Process ID (PID) and command that opened them.
- E.g., running lsof -i lists all network files/sockets, which is extremely useful for discovering which process is listening on a specific network port (like port 80).
lsof to see all open files in the system.Command Syntax Reference
| Command / Syntax | Description |
|---|---|
lsof | List all open files on the system |
Verification Objectives
These conditions will be automatically verified when you run commands inside the interactive terminal simulator:
- ○Run the "lsof" command
Ready to complete Quest 62?
Test your skills live in the browser terminal with an emulated Linux filesystem, real-time command evaluation, and instant step-by-step hints.