How to use tcpdump

Hackbydoing Academy tool guide · Traffic capture & analysis · free, no login

What tcpdump is, in plain words

Tcpdump watches traffic passing through a network card and prints or records the packets (the small chunks data travels in) as they go by.

A working tcpdump command

tcpdump -i eth0 -nn -c 10

This captures the first 10 packets seen on the eth0 card and prints them with raw numbers, with no name lookups.

Every piece of the command, explained

-APrint each packet's contents as readable text (ASCII) as well as the headers, which is how you read things sent unencrypted, like old-style FTP logins.
-cThe next number is a count: stop after capturing that many packets.
-iThe next piece is the name of the network card (interface) to listen on, such as eth0.
-nnThe letter n twice means look up nothing: show IP addresses and port numbers as raw numbers instead of converting them to names, which is faster and avoids extra traffic.
-rThe next piece is the name of a saved capture file to read back and display, instead of listening live.
-wThe next piece is the name of a file to write the captured packets into, so you can open the recording later in tcpdump or Wireshark.
filterWords at the end, such as host 192.168.99.20 and port 21, narrow the capture to only the packets that match, so you see one conversation instead of everything.

Use it the legal way

Only run tcpdump on systems you own or have explicit, written permission to test — at work that means a signed engagement, at home that means your own lab. Inside Hackbydoing Academy you practice on simulated networks and lab machines built for exactly this, where breaking things is the lesson and no one else's systems are involved. Learning how a tool works also teaches you what it looks like from the defender's chair: the logs it leaves, the traffic it makes, and the settings that shut it down.

✦ Practice tcpdump hands-on in a guided lab

Reading about tcpdump is step one. In the Academy you run it yourself, step by step, in guided labs on simulated networks — 185 rooms covering attack and defense, from your first scan to full operations, with a defender's debrief at the end of every room. Founding membership is $9.99/mo for the first 500 members.

Join Hackbydoing Academy →

Related tool guides

Free from the Hackbydoing Academy — learn cybersecurity by doing: real tools, guided labs, attack and defense, on simulated networks. More free material: Tool Guides index · Free Downloads Library · Hackbydoing Academy · Print this page (Ctrl/Cmd+P) for a clean paper copy.