Name of the command running on each port
This absurd "one-liner" will show you the name of the command running on each port on MacOS, which is something I need to do constantly so leaving it here:
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](https://x.com/search?q=%24port&src=cashtag_click): $(ps -p [$pid](https://x.com/search?q=%24pid&src=cashtag_click) -o command= | sed 's/^-//') (PID: [$pid](https://x.com/search?q=%24pid&src=cashtag_click))"; done | sort -n
![[Pasted image 20240813092553.png]]