Given a TCP/UDP port number, how do I find out the name of the service bound to that port?
I want to do this on various flavours of Unix. Mostly Gnu/Linux (usually Debian) and Mac OS X.
Super User is a question and answer site for computer enthusiasts and power users. It only takes a minute to sign up.
Sign up to join this communityGiven a TCP/UDP port number, how do I find out the name of the service bound to that port?
I want to do this on various flavours of Unix. Mostly Gnu/Linux (usually Debian) and Mac OS X.
On Linux that's
ss -lntp
ss -lnup
for TCP and UDP, respectively. l
stands for listening, p
returns the process number that's listening on the port, and n
is my pet peeve, it does not convert IP addresses into names.
On Mac OS you may use the following command, which also works on Linux:
lsof -n -i4TCP:$PORT | grep LISTEN
i4 specifies that you are using IPv4, the rest should be self-explanatory.
You can also use (on Linux)
netstat -pntl | grep $PORT
but netstat is by now obsolete, or
fuser -n tcp $PORT
which is not. That's as far as I go.