| name | process-tree |
| description | View the system process hierarchy as a tree with resource usage. Use when exploring parent-child process relationships, finding what process owns a port, monitoring CPU/memory, or sending signals. Triggers include "process tree", "ptree", "what is running", "process on port", "pstree", "who owns port", "kill process". |
process-tree
CLI tool for visualizing the system process hierarchy with resource usage.
Quick Start
ptree
ptree --port 3000
ptree --name node
ptree info 8421
ptree watch
Tree View
ptree
ptree --root 8421
ptree --compact
ptree --sort cpu
ptree --sort mem
Filter
ptree --name node
ptree --port 3000
ptree --user deploy
ptree --min-cpu 5
ptree --min-mem 200
Find (flat table)
ptree find node
ptree find --port 5432
ptree find --user www
Process Info
ptree info 8421
Kill
ptree kill 8421
ptree kill 8421 --yes
ptree kill 8421 --signal SIGKILL
ptree kill 8421 --subtree
Watch Mode
ptree watch
ptree watch --interval 5
ptree watch --name node
Press q or Ctrl-C to exit watch mode.
CLI Reference
| Command/Flag | Description |
|---|
| (default) | Show full process tree |
find <name> | Flat table of matching processes |
info <pid> | Detailed info for one process |
kill <pid> | Send SIGTERM to process |
watch | Continuously refresh tree |
--name <text> | Filter by process name |
--port <N> | Filter by listening port |
--user <name> | Filter by user |
--root <pid> | Show subtree from PID |
--min-cpu <N> | Minimum CPU % threshold |
--min-mem <N> | Minimum memory MB threshold |
--sort cpu|mem | Sort children by resource |
--compact | Collapse same-name siblings |
--interval <N> | Watch refresh interval (seconds) |
--subtree | Apply kill to whole subtree |
--signal <name> | Signal to send (SIGTERM or SIGKILL) |
--yes | Skip confirmation prompts |
--no-color | Disable ANSI color |
Environment Variables
| Variable | Default | Description |
|---|
PTREE_NO_COLOR | 0 | Disable ANSI color (1 to disable) |
PTREE_INTERVAL | 2 | Watch mode refresh interval (seconds) |
PTREE_DEBUG | 0 | Enable debug logging (1 to enable) |
Exit Codes
| Code | Meaning |
|---|
| 0 | Success |
| 1 | No processes matched |
| 2 | Permission denied |
| 3 | Runtime error |
Platform Support
Supported: macOS, Linux. Not supported: Windows (exits with clear error message).