I need to find out what ports are attached to which processes on a Unix machine (HP Itanium). Unfortunately, lsof
is not installed and I have no way of installing it.
Does anyone know an alternative method? A fairly lengthy Googling session hasn't turned up anything.
netstat -l (assuming it comes with that version of UNIX)
Given (almost) everything on unix is a file, and lsof lists open files...
Linux :
netstat -putan or lsof | grep TCP
OSX :
lsof | grep TCP
Other Unixen :
lsof
way...Assuming this is HP-UX? What about the Ptools - do you have those installed? If so you can use "pfiles" to find the ports in use by the application:
for f in $(ps -ex | awk '{print $1}'); do echo $f; pfiles $f | grep PORTNUM; done
switch PORTNUM for the port number. :) may be child pid, but gets you close enough to identify the problem app.
gives you the active tcp/udp ports. Then you can use the ports with
fuser -n tcp
orfuser -n udp
, as root, and supposing thatfuser
is GNU fuser or has similar options.If you need more help, let me know.
Which process uses port in unix;
1. netstat -Aan | grep port
2. rmsock f1000e000bb5c3b8 tcpcb
3. ps -ef | grep 13959354
EDIT: linux only, on other UNIXes netstat may not support all these options.