Skip to content

Commit

Permalink
fix: added scan-ports
Browse files Browse the repository at this point in the history
  • Loading branch information
ErikBjare committed Aug 13, 2024
1 parent 2443b28 commit 37b6fce
Showing 1 changed file with 9 additions and 0 deletions.
9 changes: 9 additions & 0 deletions home/.bin/scan-ports
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
#!/bin/bash

if [ "$(uname)" == "Darwin" ]; then
# https://x.com/seldo/status/1823126087423099192
sudo lsof -iTCP -sTCP:LISTEN -n -P | awk 'NR>1 {print $9, $1, $2}' | sed 's/.*://' | while read port process pid; do echo "$port: $(ps -p $pid -o command= | sed 's/^-//') (PID: $pid)"; done | sort -n
else
# on Linux
sudo netstat -tulnp | grep LISTEN
fi

0 comments on commit 37b6fce

Please sign in to comment.