1234567891011121314151617 |
- #!/bin/bash
- ##############
- # Returns the name of the service
- # running on a given port.
- ##############
- if [ ! "$UID" = 0 ]; then
- echo "Must be ran as root"
- exit 1
- fi
- if [ ! "$1" -gt 0 ] || [ ! "$1" -lt 65536 ]; then
- echo "Port number must be in range 1 - 65535"
- exit 2
- fi
- ss -tulpn | grep LISTEN | grep -E ":$1\b" | grep -Po "(?<=\(\(\").+?(?=\")" | uniq
|