4

I'm running a RedHat 5.5 and I was wondering how I can identify a port to a process.

This is the output of netstat and I'm trying to find the process associated with port 35670:

$ netstat -tulnp
tcp        0      0 0.0.0.0:35670               0.0.0.0:*                   LISTEN      -

I tried the following to get the associated process to this port, but to no avail:

$ lsof -nl | grep TCP
$ fuser 35670/tcp

This finally worked for me.

$ rpcinfo -p
100021    3   tcp  35670  nlockmgr

Without doing the command above, how would you have detected that port 35670 is associated with nlockmgr.

The weird thing is nlockmgr does not show up when I do this:

$ ps aux
Carmen
  • 817

3 Answers3

7

You have to execute netstat -tulnp as root. Otherwise you get the - instead of the process name.

This is what the manpage says:

PID/Program name
   Slash-separated pair of the process id (PID) and process name of the process that owns the socket.  --program causes  this  column
   to  be  included.   You will also need superuser privileges to see this information on sockets you don't own.  This identification
   information is not yet available for IPX sockets.

With one exception: portmapper See this

mailq
  • 17,251
2

You can use nmap with -sV option to determine service info:

# nmap -sV -p 35670 localhost

Why is rpc.lockd obscured from netstat/lsof output?

quanta
  • 52,423
0

Instead of netstat you can use ss:

[mvutcovi@mvutcovi-lap ~]$ sudo ss -tulnp
Netid    State     Recv-Q    Send-Q         Local Address:Port          Peer Address:Port                                                
udp      UNCONN    0         0              192.168.122.1:53                 0.0.0.0:*        users:(("dnsmasq",pid=1698,fd=5))          
udp      UNCONN    0         0             0.0.0.0%virbr0:67                 0.0.0.0:*        users:(("dnsmasq",pid=1698,fd=3))          
udp      UNCONN    0         0                    0.0.0.0:68                 0.0.0.0:*        users:(("dhclient",pid=1980,fd=7))