Difference between revisions of "Netstat"

From wikieduonline
Jump to navigation Jump to search
Tags: Mobile web edit, Mobile edit
 
(16 intermediate revisions by 4 users not shown)
Line 1: Line 1:
<code>Netstat</code>is a command to displays [[network]] statistics. <code>Netstat</code> is at least available in [[AIX]], [[Linux]]<ref>http://man7.org/linux/man-pages/man8/netstat.8.html</ref>, [[macOS]] and [[Windows]]  
+
{{lc}}<code>netstat</code>is a command to displays [[network]] statistics. <code>Netstat</code> is at least available in [[AIX]], [[Linux]]<ref>http://man7.org/linux/man-pages/man8/netstat.8.html</ref>, [[macOS]] and [[Windows]]  
  
 
* Package: <code>[[net-tools]]</code>
 
* Package: <code>[[net-tools]]</code>
Line 5: Line 5:
 
== Linux Examples ==
 
== Linux Examples ==
 
* <code>[[netstat -vatunp]]</code> or <code>netstat -lnpt</code><ref>https://unix.stackexchange.com/a/9254</ref>. See also: <code>[[ss]] -ap</code><ref>https://unix.stackexchange.com/a/9254</ref>, <code>ss -ta</code> and <code>[[lsof]]</code>
 
* <code>[[netstat -vatunp]]</code> or <code>netstat -lnpt</code><ref>https://unix.stackexchange.com/a/9254</ref>. See also: <code>[[ss]] -ap</code><ref>https://unix.stackexchange.com/a/9254</ref>, <code>ss -ta</code> and <code>[[lsof]]</code>
  -l show only listening sockets
+
  -l show only [[listening]] sockets
 
  -p --program Show the PID and name (PID/name) of the program to which each socket belong
 
  -p --program Show the PID and name (PID/name) of the program to which each socket belong
 
  -t --tcp
 
  -t --tcp
Line 19: Line 19:
  
 
== [[macOS]] examples ==
 
== [[macOS]] examples ==
* <code>netstat -ap tcp</code>
+
* <code>[[netstat -anp tcp]]</code>
** <code>netstat -ap tcp | grep LISTEN</code>
+
** <code>[[netstat -anp tcp ]]| grep [[LISTEN]]</code>
 +
 
 +
* <code>[[netstat -atp tcp]]</code>
 +
** <code>[[netstat -atp tcp]] | grep [[rfb]]</code>
  
 
== Windows examples ==
 
== Windows examples ==
* <code>netstat -an</code>
+
* <code>[[netstat -an]]</code>
 
** <code>netstat -an | [[findstr]] PORT_NUMBER</code>
 
** <code>netstat -an | [[findstr]] PORT_NUMBER</code>
 
* <code>netstat -ab</code> or <code>[[Get-Process]] -Id (Get-NetTCPConnection -LocalPort portNumber).OwningProcess</code>
 
* <code>netstat -ab</code> or <code>[[Get-Process]] -Id (Get-NetTCPConnection -LocalPort portNumber).OwningProcess</code>
 
: <code>-b</code> displays the executable involved in creating each connection or listening port.
 
: <code>-b</code> displays the executable involved in creating each connection or listening port.
  
== Related commands ==
+
== Related ==
* <code>[[nethogs]]</code>
+
* <code>[[nethogs]]</code> command for checking [[network bandwidth]] used by individual processes
* [[PAN-OS]]: <code>[[show session all]]</code>
+
* [[PAN-OS]]: <code>[[show session all]]</code>, <code>[[show netstat statistics yes]]</code>
 +
* <code>[[command not found]]</code>
 +
* <code>[[/proc/net/netstat]]</code>
 +
* [[IP forwarding]]
  
 
== See also ==
 
== See also ==
 +
* {{netstat}}
 
* [[Script to use if netstat not available]]
 
* [[Script to use if netstat not available]]
* {{lsoft}}
+
* {{lsof}}
 
* {{Linux networking commands}}
 
* {{Linux networking commands}}
 
* {{Ethernet}}
 
* {{Ethernet}}

Latest revision as of 17:09, 18 December 2023

netstatis a command to displays network statistics. Netstat is at least available in AIX, Linux[1], macOS and Windows

Linux Examples[edit]

-l show only listening sockets
-p --program Show the PID and name (PID/name) of the program to which each socket belong
-t --tcp
  • netstat -vatunp
-v --verbose
-a --all
  • netstat -tn or netstat --tcp -n (TCP connections)
  • netstat -rn IP routes

macOS examples[edit]

Windows examples[edit]

-b displays the executable involved in creating each connection or listening port.

Related[edit]

See also[edit]

  • http://man7.org/linux/man-pages/man8/netstat.8.html
  • https://unix.stackexchange.com/a/9254
  • https://unix.stackexchange.com/a/9254
  • Advertising: