dotfiles/home/bin/what_ports

4 lines
218 B
Plaintext
Raw Permalink Normal View History

2024-11-01 18:52:50 +00:00
#!/bin/bash
sudo lsof -iTCP -sTCP:LISTEN -n -P | awk 'NR>1 {print $9, $1, $2}' | sed 's/.*://' | while read port process pid; do echo "Port $port: $(ps -p $pid -o command= | sed 's/^-//') (PID: $pid)"; done | sort -n