0Pricing
Linux Command Line Mastery · Lesson

Capturing and Inspecting Traffic with tcpdump

Round out your networking and security toolkit by capturing live packets and applying filters with tcpdump to diagnose connectivity and security issues.

Capturing and Inspecting Traffic with tcpdump is a free Linux Command Line Mastery lesson on CoddyKit — lesson 4 of 4. You can read the complete lesson below for free — then practise it hands-on in the browser with a built-in code editor and a 24/7 AI tutor. It is part of the Linux Command Line Mastery learning path, one of 4 lessons in the course, and your progress syncs across the web and the CoddyKit app.

Seeing the Wire

Diagnostics like ping and dig tell you whether something works, but sometimes you need to see the actual packets. tcpdump captures network traffic in real time.

Listing Interfaces

First find which interface to listen on with -D. Common names are eth0, wlan0, or en0.

sudo tcpdump -D

A Basic Capture

-i selects the interface. Capturing requires root because it reads raw packets.

sudo tcpdump -i eth0

Limiting the Capture

-c stops after N packets so the terminal does not flood, useful for a quick look.

sudo tcpdump -i eth0 -c 10

Filtering by Host

Capture filters narrow the noise. host limits to traffic to/from one address.

sudo tcpdump -i eth0 host 8.8.8.8

Filtering by Port

Use port to focus on a service. Here we watch only HTTPS traffic.

sudo tcpdump -i eth0 port 443

Combining Filters

Filters combine with and, or, not for precise targeting.

sudo tcpdump -i eth0 tcp and port 22 and not host 10.0.0.1

Readable Output Flags

-n skips DNS lookups (faster, shows IPs), and -v adds detail. -A prints packet payloads as ASCII.

sudo tcpdump -i eth0 -nv port 80

Saving to a File

-w writes raw packets to a .pcap file you can analyze later, e.g. in Wireshark.

sudo tcpdump -i eth0 -w capture.pcap

Reading a Capture

-r replays a saved capture, and you can still apply filters while reading.

tcpdump -r capture.pcap port 443

Security Use Cases

tcpdump helps spot unexpected outbound connections, confirm a firewall rule is blocking traffic, or verify that sensitive data is encrypted on the wire.

Quick Check

What does the -w option do in tcpdump?

Recap

You can now inspect live traffic:

  • -i picks the interface, -c limits count
  • Filters: host, port, combined with and/or/not
  • -n/-v/-A shape output
  • -w saves and -r reads .pcap files

tcpdump turns invisible packets into a debuggable stream.

Frequently asked questions

Is the “Capturing and Inspecting Traffic with tcpdump” lesson free?

Yes — the full text of “Capturing and Inspecting Traffic with tcpdump” is free to read here on the web, and the Linux Command Line Mastery course includes 4 lessons in total. To practise it interactively (a built-in code editor and a 24/7 AI tutor) and unlock the rest of the Linux Command Line Mastery course, upgrade to CoddyKit PRO.

What will I learn in “Capturing and Inspecting Traffic with tcpdump”?

Round out your networking and security toolkit by capturing live packets and applying filters with tcpdump to diagnose connectivity and security issues. You practise Linux Command Line Mastery with hands-on code you run directly in the browser, and a 24/7 AI tutor answers your questions as you work through the lesson.

Do I need any experience to start Linux Command Line Mastery?

No prior experience is required. Linux Command Line Mastery on CoddyKit is structured for beginners through advanced learners; this is — lesson 4 of 4, so you can start here or from the beginning and move at your own pace.

How long does the “Capturing and Inspecting Traffic with tcpdump” lesson take?

Most CoddyKit lessons take about 5–10 minutes. Each one is bite-sized and interactive, so you make steady progress and pick up exactly where you left off across the web and the app.

Can I write and run code in this Linux Command Line Mastery lesson?

Yes. Every Linux Command Line Mastery lesson includes a built-in code editor, so you write and run real code right in your browser and get instant AI feedback — no local setup required.

All lessons in this course

  1. Network Diagnostics: `traceroute`, `nslookup`, `dig`
  2. Firewall Management: `ufw`, `firewalld`, `iptables`
  3. Secure Shell Key Management
  4. Capturing and Inspecting Traffic with tcpdump
← Back to Linux Command Line Mastery