tcpdump

Capture and analyze raw network packets on a network interface.

low risk

interactive breakdown — edit the command and press Explain
$ 
⚠ Risks & cautions
What it does

tcpdump captures packets matching Berkeley Packet Filter (BPF) expressions. Requires root. -i specifies the interface. Write to .pcap files for analysis in Wireshark.

Common flags
FlagMeaning
-iNetwork interface to capture on (use 'any' for all)
-nDon't resolve hostnames or port names
-wWrite packets to a .pcap file
-cExit after capturing N packets
Examples
tcpdump -i eth0 -n port 80 -w /tmp/http.pcapCapture HTTP traffic to file for Wireshark analysis · explain & risk-check →
tcpdump -i any -n 'host 10.0.1.5 and port 5432'Capture PostgreSQL traffic to/from a specific host · explain & risk-check →
tcpdump -i eth0 -n -c 100 port 53Capture 100 DNS queries and exit · explain & risk-check →
Pro tip

Combine with -G and -W to auto-rotate capture files: `-G 60 -W 10` keeps 10 files of 60 seconds each.

Related
nmap ss iptables tshark
Open the full explainer →More in Networking

Reference text is hand-written and may be incomplete — check man tcpdump for your version. Test destructive commands on a non-production system first.