Lsof

From x-cmd/x-cmd · View interactive version

Lsof is an AI agent skill from the GitHub repository x-cmd/x-cmd. Enhanced lsof (List Open Files) with interactive UI and structured output. View open files, network connections, and processes. **Dependency**: This is an x-cmd module. Install x-cmd first (see x-cmd skill for installation options). see x-cmd skill for installation.

How to use this skill

Skill file

x lsof - List Open Files

Enhanced lsof with interactive UI, fzf search, and TSV/CSV/JSON output formats.


Quick Start

# Interactive view (default in TTY)
x lsof

# fzf interactive search
x lsof fz

# TSV format output
x lsof --tsv

Features


Commands

| Command | Description |

|---------|-------------|

| x lsof | Interactive TUI view (default in TTY) / TSV (piped) |

| x lsof fz | Interactive fzf search |

| x lsof --app | TUI application view |

| x lsof --tsv | TSV format output |

| x lsof --csv | CSV format output |

| x lsof --raw | Raw format output |

| x lsof --pidofport <port> | Find PID by port number |


Examples

Basic Usage

# Interactive view (TTY default)
x lsof

# fzf interactive mode
x lsof fz

# TSV format for processing
x lsof --tsv

# CSV format
x lsof --csv

Find Process by Port

# Find PID listening on port 8080
x lsof --pidofport 8080

# Find all processes using port 443
x lsof -i:443

Data Processing

# Filter with awk
x lsof --tsv | awk -F'\t' '$2 == "TCP"'

# Import to spreadsheet
x lsof --csv > open_files.csv

# Count files by process
x lsof --tsv | cut -f1 | sort | uniq -c | sort -rn

Output Fields

| Field | Description |

|-------|-------------|

| COMMAND | Process name |

| PID | Process ID |

| USER | User name |

| FD | File descriptor |

| TYPE | File type (REG, DIR, IPv4, IPv6) |

| DEVICE | Device number |

| SIZE/OFF | File size or offset |

| NODE | Inode number |

| NAME | File name / network connection |


Automatic Binary Download

If lsof is not installed on your system, x-cmd automatically downloads a portable version from trusted sources (pixi/conda-forge) and manages it locally. No manual installation required.

Supported platforms:


Platform Notes


Related

Use this skill with your AI agent: Open on Skill Issue to copy, download, or add to your library. Works with Claude, ChatGPT, Gemini, Cursor, Windsurf and more.