For When You Can't Have The Real Thing
[ start | index | login ]
start > Linux > What Program Has This Port Open

What Program Has This Port Open

Created by dave. Last edited by dave, one year and 215 days ago. Viewed 5,442 times. #2
[diff] [history] [edit] [rdf]
labels
attachments

How do I associate an open port with a running program?

eg: what is listening on port 22?

# lsof -i :22
COMMAND   PID USER   FD   TYPE    DEVICE SIZE NODE NAME
sshd     1318 root    3u  IPv4      2444       TCP *:ssh (LISTEN)
sshd     7665 root    4u  IPv4 166534123       TCP netbackup:ssh->router:918 (ESTABLISHED)
sshd    19710 root    4u  IPv4 554877146       TCP netbackup:ssh->router:853 (ESTABLISHED)

eg: what is listening on port smpt (the mail port)?

# lsof -i :smtp
COMMAND    PID USER   FD   TYPE   DEVICE SIZE NODE NAME
sendmail 25860 root    4u  IPv4 66767220       TCP *:smtp (LISTEN)

New hotness: ss

# ss -tln
State             Recv-Q            Send-Q                       Local Address:Port                       Peer Address:Port            Process
LISTEN            0                 4096                             127.0.0.1:199                             0.0.0.0:*
LISTEN            0                 128                                0.0.0.0:22                              0.0.0.0:*
LISTEN            0                 128                                   [::]:22                                 [::]:*
where:
  • -l means listen
  • -t means tcp ports
  • -n means show numbers rather than names
no comments | post comment
This is a collection of techical information, much of it learned the hard way. Consider it a lab book or a /info directory. I doubt much of it will be of use to anyone else.

Useful:


snipsnap.org | Copyright 2000-2002 Matthias L. Jugel and Stephan J. Schmidt