The Wiert Corner – irregular stream of stuff

Jeroen W. Pluimers on .NET, C#, Delphi, databases, and personal interests

  • My badges

  • Twitter Updates

  • My Flickr Stream

  • Pages

  • All categories

  • Enter your email address to subscribe to this blog and receive notifications of new posts by email.

    Join 4,265 other subscribers

*nix networking – lsof: How to tell what process has a specific port open on Linux (via: Server Fault)

Posted by jpluimers on 2014/01/10

I usually used netstat with some grep filter for this, but Brandon Titus showed at StackOverflow that the lsof command is much easier to use:

lsof command should be able to do this just fine. Just use this:

lsof -i :<port_number>
lsof -i udp:<port_number>
lsof -i tcp:<port_number>

and all of the processes should come up.

The lsof commands work on SUSE, Max OS X, CygWin and many other environments.

(update 20160304: added more arguments and links)

Two other commands I use often:

netstat -tulpn | sort

(for connected and listening tcp/udp ports it shows processes and port numbers; see the netstat parameters for more details, note that -u includes udp and -l adds listening sockets)

rpcinfo -p ; rpcinfo -s

(shows the ports used by rpcbind)

Note that one day I’ll learn the iproute2 equivalents (many of which have non descriptive 2 letter names like ip, iw, ss, tc, maybe because iproute2), but as OS X still doesn’t have iproute2, I’m hesitating. Anyway, that day:

–jeroen

via

One Response to “*nix networking – lsof: How to tell what process has a specific port open on Linux (via: Server Fault)”

  1. […] friday I updated the examples at *nix networking – lsof: How to tell what process has a specific port open on Linux (via: Server Fa… as I needed to document some of the machines around here (so it becomes easier replacing […]

Leave a comment

This site uses Akismet to reduce spam. Learn how your comment data is processed.