如何识别进程的端口?

Car*_*men 4 linux port process

我正在运行 a RedHat 5.5,我想知道如何识别进程的端口。

这是输出,netstat我正在尝试查找与 port 关联的进程35670

$ netstat -tulnp
tcp        0      0 0.0.0.0:35670               0.0.0.0:*                   LISTEN      -
Run Code Online (Sandbox Code Playgroud)

我尝试了以下方法将相关进程获取到此端口,但无济于事:

$ lsof -nl | grep TCP
$ fuser 35670/tcp
Run Code Online (Sandbox Code Playgroud)

这最终对我有用。

$ rpcinfo -p
100021    3   tcp  35670  nlockmgr
Run Code Online (Sandbox Code Playgroud)

如果不执行上述命令,您将如何检测到该端口35670nlockmgr.

奇怪的是nlockmgr当我这样做时没有出现:

$ ps aux
Run Code Online (Sandbox Code Playgroud)

mai*_*ilq 7

您必须以netstat -tulnproot身份执行。否则,您将获得-而不是进程名称。

这是手册页所说的:

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.
Run Code Online (Sandbox Code Playgroud)

除了一个例外:portmapper 看到这个