Forrest logo
tool overview
On this page you find all important commands for the CLI tool lsof. If the command you are looking for is missing please ask our AI.

lsof

lsof is a command meaning "list open files", which is used in many Unix-like systems to report a list of all open files and the processes that opened them. This open source utility was developed and supported by Victor A. Abell, the retired Associate Director of the Purdue University Computing Center. It works in and supports several Unix flavors

List of commands for lsof:

  • linux:system:ports:open Show all open ports
    $ lsof -i -P -n | grep LISTEN
    try on your machine
  • lsof:tldr:055e0 lsof: Find the processes that have a given file open.
    $ lsof ${filename}
    try on your machine
    explain this command
  • lsof:tldr:0eb6b lsof: List files opened by a specific process, given its PID.
    $ lsof -p ${PID}
    try on your machine
    explain this command
  • lsof:tldr:1e9ee lsof: List files opened by the given user.
    $ lsof -u ${username}
    try on your machine
    explain this command
  • lsof:tldr:1ef8a lsof: List files opened by the given command or process.
    $ lsof -c ${process_or_command_name}
    try on your machine
    explain this command
  • lsof:tldr:24de7 lsof: Only output the process ID (PID).
    $ lsof -t ${filename}
    try on your machine
    explain this command
  • lsof:tldr:8d9eb lsof: List open files in a directory.
    $ lsof +D ${path-to-directory}
    try on your machine
    explain this command
  • lsof:tldr:ceae6 lsof: Find the process that is listening on a local IPv6 TCP port and don't convert network or port numbers.
    $ lsof -i6TCP:${port} -sTCP:LISTEN -n -P
    try on your machine
    explain this command
  • lsof:tldr:e93b3 lsof: Find the process that opened a local internet port.
    $ lsof -i :${port}
    try on your machine
    explain this command
  • shell:warp:c888b List processes at port
    $ lsof -i:${port}
    try on your machine
    explain this command
tool overview