Skip to content

lsof command

List open files and the processes that hold them, including network ports.

On this page

Syntax

lsof [options]

Provided by the lsof package. Run man lsof for the full manual.

Common options

OptionWhat it does
-i :PORTProcesses using a port
-i TCPTCP connections
-u USERFiles a user has open
-p PIDFiles a process has open
-tPrint PIDs only
+D DIROpen files under a directory

Examples

  1. What is using port 8080

    sudo lsof -i :8080
  2. PIDs only (for kill)

    sudo lsof -t -i :8080
  3. Open files of a process

    sudo lsof -p 1234
  4. Who has a file open

    sudo lsof /var/log/syslog
  5. Deleted files still taking space

    sudo lsof | grep deleted

← All Linux commands · Suggest a fix

Back to top