1. netstat -Aan | grep <Port Name>
– This shows if the specified is being used. The hex number in the first column is the address of protocol control block (PCB)
bash-3.00# netstat -Aan | grep 32775
f100060000942398 tcp4 0 0 *.32775 *.* LISTEN
2. rmsock tcpcb
– This shows the process who is holding the socket. Note that this command must be run as root.
bash-3.00# rmsock f100060000942398 tcpcb
The socket 0x942008 is being held by Kernel/Kernel Extension.
AIX Example
1. bash-3.00# netstat -An | grep 1522
f100060002e69b98 tcp4 0 0 10.1.100.45.1522 10.1.53.182.2293 ESTABLISHED
f100060001ecbb98 tcp4 0 0 10.1.100.45.1522 10.1.53.182.2299 ESTABLISHED
f100060003ae2398 tcp4 0 0 10.1.100.45.1522 10.1.53.182.2302 ESTABLISHED
f100060003a13b98 tcp4 0 0 10.1.100.45.1522 10.1.53.182.2318 ESTABLISHED
f100060003f7cb98 tcp4 0 0 10.1.100.45.1522 10.1.53.182.2320 ESTABLISHED
f100060003f28b98 tcp4 0 0 10.1.100.45.1522 10.1.53.182.2332 ESTABLISHED
f100060002eb7398 tcp4 0 0 10.1.100.45.1522 10.1.53.182.2335 ESTABLISHED
f100060003e09398 tcp4 0 0 10.1.100.45.1522 10.1.53.182.2336 ESTABLISHED
f100060003bf0b98 tcp4 0 0 10.1.100.45.1522 10.1.53.182.2337 ESTABLISHED
f100060003a22398 tcp4 0 0 10.1.100.45.1522 10.1.53.182.2338 ESTABLISHED
f100060003e27398 tcp4 0 0 10.1.100.45.1522 10.1.53.182.2346 ESTABLISHED
f1000600003e2398 tcp4 0 0 10.1.100.45.1522 10.1.53.182.2349 ESTABLISHED
f100060003be3398 tcp4 0 0 10.1.100.45.1522 10.1.53.182.2350 ESTABLISHED
f100060000356398 tcp4 0 0 10.1.100.45.1522 10.1.53.191.2916 ESTABLISHED
f100060003925398 tcp4 0 0 10.1.100.45.1522 10.1.50.100.4234 TIME_WAIT
f1000600039a4398 tcp4 0 0 10.1.100.45.1522 10.1.50.100.4237 TIME_WAIT
f100060003c42398 tcp4 0 0 10.1.100.45.1522 10.1.50.100.4242 TIME_WAIT
f100060003aea398 tcp4 0 0 10.1.100.45.1522 10.1.53.126.4169 ESTABLISHED
f10006000394c398 tcp4 0 0 10.1.100.45.1522 10.1.53.126.4170 ESTABLISHED
f100060003e53398 tcp4 0 0 10.1.100.45.1522 10.1.53.159.4763 ESTABLISHED
f100060003b90398 tcp4 0 0 10.1.100.45.1522 10.1.53.154.4931 ESTABLISHED
bash-3.00# rmsock f100060002e69b98 tcpcb
The socket 0x2e69808 is being held by proccess 2027686 (oracle).
2. 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.
bash-3.00# db2 update dbm cfg using svcename 30542
bash-3.00# db2start
bash-3.00# netstat -Aan | grep 30542
f10000f6436321b58 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.
bash-3.00# rmsock f10000f6436321b58 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.