Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chris Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Linux 'netstat -natp' equivalent on Solaris 1

Status
Not open for further replies.

nychris

MIS
Dec 4, 2004
103
US
Is there an equivalent command in Solaris to 'netstat -natp' on any Linux machine? That command will show you all the ports that are in use and which PID is attached to each one. For example, if I wanted to see if port 80 was in use, I would do...
Code:
root@usilap34t root# netstat -nat | grep :80
tcp        0      0 0.0.0.0:80              0.0.0.0:*               LISTEN
Now, if I wanted to see which process was attached to port 80...
Code:
root@usilap34t root# netstat -natp | grep :80
tcp        0      0 0.0.0.0:80              0.0.0.0:*               LISTEN      18018/httpd
What is the easiet way to do this on Solaris since those options to netstat don't exist?

Thanks



 
First look at man netstat... Running netstat -anv seem to give the information you are looking for.
 
That doesn't show you the PID or process name that is binding to each port.

Code:
bash-2.03# netstat -anv | grep 80
152.212.99.103.80
      *.80

bash-2.03# ps -ef|grep httpd | grep -v grep
    root 15048     1  0   Nov 28 ?        0:00 /usr/local/apache2/bin/httpd
  nobody 15049 15048  0   Nov 28 ?        0:00 /usr/local/apache2/bin/httpd
  nobody 15053 15048  0   Nov 28 ?        0:00 /usr/local/apache2/bin/httpd
  nobody  4237 15048  0   Dec 08 ?        0:00 /usr/local/apache2/bin/httpd
    root  1355  1354  0   Apr 29 ?        0:01 ns-httpd -d /opt/SUNW/webserver4.1/https-admserv/config
  nobody  7167  1384  0   May 01 ?       105:26 ns-httpd -d /opt/SUNW/webserver4.1/https-usilsutn.ca.com/config
  nobody 15052 15048  0   Nov 28 ?        0:00 /usr/local/apache2/bin/httpd
  nobody  4234 15048  0   Dec 08 ?        0:00 /usr/local/apache2/bin/httpd
  nobody  4236 15048  0   Dec 08 ?        0:00 /usr/local/apache2/bin/httpd
  nobody  4235 15048  0   Dec 08 ?        0:00 /usr/local/apache2/bin/httpd
  nobody 15050 15048  0   Nov 28 ?        0:00 /usr/local/apache2/bin/httpd
  nobody 15051 15048  0   Nov 28 ?        0:00 /usr/local/apache2/bin/httpd
  nobody  4238 15048  0   Dec 08 ?        0:00 /usr/local/apache2/bin/httpd
 
thanks huebs, that did it...
Code:
[usilap11 /]# lsof -i |grep :80
httpd      4750     root    3u  IPv6 0x7149802c        0t0  TCP *:80 (LISTEN)
httpd      4751   nobody    3u  IPv6 0x7149802c        0t0  TCP *:80 (LISTEN)
httpd      4752   nobody    3u  IPv6 0x7149802c        0t0  TCP *:80 (LISTEN)
httpd      4753   nobody    3u  IPv6 0x7149802c        0t0  TCP *:80 (LISTEN)
httpd      4754   nobody    3u  IPv6 0x7149802c        0t0  TCP *:80 (LISTEN)
httpd      4755   nobody    3u  IPv6 0x7149802c        0t0  TCP *:80 (LISTEN)
httpd     12187   nobody    3u  IPv6 0x7149802c        0t0  TCP *:80 (LISTEN)
httpd     12188   nobody    3u  IPv6 0x7149802c        0t0  TCP *:80 (LISTEN)
httpd     12189   nobody    3u  IPv6 0x7149802c        0t0  TCP *:80 (LISTEN)
[usilap11 /]# ps -ef |grep httpd
  nobody 12188  4750  0   Jan 04 ?        0:08 /usr/local/apache2052/bin/httpd -k start
  nobody  4753  4750  0   Dec 31 ?        0:00 /usr/local/apache2052/bin/httpd -k start
  nobody  4754  4750  0   Dec 31 ?        0:00 /usr/local/apache2052/bin/httpd -k start
  nobody  4751  4750  0   Dec 31 ?        0:05 /usr/local/apache2052/bin/httpd -k start
  nobody 12187  4750  0   Jan 04 ?        0:02 /usr/local/apache2052/bin/httpd -k start
  nobody  4755  4750  0   Dec 31 ?        0:00 /usr/local/apache2052/bin/httpd -k start
    root  4750     1  0   Dec 31 ?        0:01 /usr/local/apache2052/bin/httpd -k start
  nobody 12189  4750  0   Jan 04 ?        0:03 /usr/local/apache2052/bin/httpd -k start
  nobody  4752  4750  0   Dec 31 ?        0:04 /usr/local/apache2052/bin/httpd -k start
    root 13300 13162  0 09:41:26 pts/2    0:00 grep httpd
[usilap11 /]#

--
Chris
RHCE, LPIC, CNE, CCNA, MCSE (+11 others)
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top