Last active
August 29, 2015 14:11
-
-
Save shamil/84bb07d55f3a20b4e2dc to your computer and use it in GitHub Desktop.
Some commands to find out listening ports
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# find all listening ports | |
cat /proc/net/tcp | awk '$4 == "0A" {print $2}' | awk -F: '{print strtonum("0x"$2)}' | |
# find all listening ports and print their inodes as well | |
cat /proc/net/tcp | awk '$4 == "0A" {print $10" "$2}' | tr : ' ' | awk '{printf "%d %d\n", strtonum("0x"$3), $1}' | |
# find all socket for PID and print their inodes | |
find -L /proc/<PID>/fd -type s -printf "%i\n" | |
# find listening ports for by PID | |
ss -ltnp4 | grep 26532 | tr -dc '0-9 \n' | |
# find all Listening ports and their PID by proccess name | |
ss -ltnp4 | grep memcached | tr , ' ' | tr -dc '0-9 \n' | awk '{print $3" "$4}' |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment