1

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.

7
  • @MariusMatutiae Various UNIX. Mostly Gnu/Linux (usually Debian) & Mac OS X.
    – voices
    Sep 24, 2015 at 7:20
  • You might want to think about rewording your question. Asking for tools/software is off-topic. If you can change the question to something like "How do I do xyz" it will be better ...
    – DavidPostill
    Sep 24, 2015 at 9:35
  • @DavidPostill You're right, it's pretty rough; I was a bit sleep deprived and in a rush at the time. If you'd like to make some changes, you're more than welcome to.
    – voices
    Sep 25, 2015 at 1:18
  • I've made some edits to your question so it doesn't look like you are asking for a tool/software recoomendation. Please review the edits to make sure that your question is still the same question you wanted to ask.
    – DavidPostill
    Sep 25, 2015 at 6:49
  • @DavidPostill I'm sure it's fine. Full disclosure (just to be clear & perfectly honest) though; I was looking for a tool recommendation.
    – voices
    Sep 25, 2015 at 7:10

1 Answer 1

2

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.

0

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .