Exemple: lsof -i :2300 ou lsof -i 4 :2300 (???)
COMMAND PID USER FD TYPE DEVICE SIZE/OFF NODE NAME UCXJAP6 516322 root 5u IPv4 0xf10007000004fbb0 0t0 TCP *:cvmmon (LISTEN)
To list all ports used by a process lsof -p $PID-a -i 4
1. netstat -Aan | grep <port number> - This shows if the specified <port number> is being used. The hex number in the first column is the address of protocol control block (PCB)
2. rmsock <addr of PCB> tcpcb - This shows the process who is holding the socket. Note that this command must be run as root.
AIX Example
Let's set SVCENAME to 30542, so that the listener will use this port. Then, use the commands above to check if the port is indeed being used by DB2 LUW.
$ db2 update dbm cfg using svcename 30542 $ db2start $ netstat -Aan | grep 30542 f10000f303321b58 tcp4 0 0 *.30542 *.* LISTEN
The netstat command, above, shows that the port 30542 is being used for listening. To confirm that it is DB2 LUW that's using the port, run rmsock as root like following.
$ rmsock f10000f303321b58 tcpcb The socket 0x3321800 is being held by proccess 692476 (db2sysc).
This shows that it's db2sysc process that's using the port, and its PID is 692476.
Note that rmsock, unlike what its name implies, does not remove the socket, if the socket is being used by any process. Instead of removing the socket, it just reports the process holding the socket. Also note that the second argument of rmsock is the protocol. It's tcpcb in the example to indicate that the protocol is TCP.