tcpdump Commands

Complete tcpdump commands reference — 63 commands across 1 categories. Quick reference cheat sheet for Linux, macOS & BSD.

tcpdump captures packets on an interface, filters them with BPF expressions, and either prints them or writes them to a pcap file for Wireshark. The table lists its options from the manual page; in practice five of them, plus the filter expression, account for nearly every capture. The notes are about those five and the mistakes that follow from omitting them.

Options (63)

ShortcutAction
tcpdump -APrint each packet (minus its link level header) in ASCII
tcpdump -bPrint the AS number in BGP packets using "asdot" rather than "asplain" representation, in RFC
tcpdump -B buffer_size --buffer-size=buffer_sizeSet the operating system capture buffer size to buffer_size, in units of KiB (1024 bytes)
tcpdump -c countExit after receiving or reading count packets
tcpdump --countPrint only on stdout the packet count when reading capture file(s) instead of parsing/prin
tcpdump -C file_sizeBefore writing a raw packet to a savefile, check whether the file is currently larger than
tcpdump -dDump the compiled packet-matching code in a human readable form to standard output and sto
tcpdump -ddDump packet-matching code as a C array of struct bpf_insn structures
tcpdump -dddDump packet-matching code as decimal numbers (preceded with a count)
tcpdump -D --list-interfacesPrint the list of the network interfaces available on the system and on which tcpdump can
tcpdump -ePrint the link-level header on each dump line
tcpdump -EUse spi@ipaddr algo:secret for decrypting IPsec ESP packets that are addressed to addr
tcpdump -fPrint `foreign' IPv4 addresses numerically rather than symbolically (this option is intend
tcpdump -F fileUse file as input for the filter expression
tcpdump -g --ip-onelineDo not insert a line break after the IP header in verbose mode
tcpdump -G rotate_secondsIf specified, rotates the dump file specified with the -w option every rotate_seconds seco
tcpdump -h --helpPrint the tcpdump and libpcap version strings, print a usage message, and exit
tcpdump --versionPrint the tcpdump and libpcap version strings and exit
tcpdump -i interface --interface=interfaceListen, report the list of link-layer types, report the list of time stamp types, or repor
tcpdump -I --monitor-modePut the interface in "monitor mode"; this is supported only on IEEE 802.11 Wi-Fi interface
tcpdump --immediate-modeCapture in "immediate mode"
tcpdump -j tstamp_type --time-stamp-type=tstamp_typeSet the time stamp type for the capture to tstamp_type
tcpdump -J --list-time-stamp-typesList the supported time stamp types for the interface and exit
tcpdump --time-stamp-precision=tstamp_precisionWhen capturing, set the time stamp precision for the capture to tstamp_precision
tcpdump --micro --nanoShorthands for --time-stamp-precision=micro or --time-stamp-precision=nano
tcpdump -K --dont-verify-checksumsDon't attempt to verify IP, TCP, or UDP checksums
tcpdump -lMake stdout line buffered
tcpdump -L --list-data-link-typesList the known data link types for the interface, in the specified mode, and exit
tcpdump --lengthsPrint the captured and original packet lengths
tcpdump -m moduleLoad SMI MIB module definitions from file module
tcpdump -M secretUse secret as a shared secret for validating the digests found in TCP segments with the TC
tcpdump -nDon't convert addresses (i.e., host addresses, port numbers, etc.) to names
tcpdump -NDon't print domain name qualification of host names
tcpdump -# --numberPrint a packet number at the beginning of the line
tcpdump -O --no-optimizeDo not run the packet-matching code optimizer
tcpdump -p --no-promiscuous-modeDon't put the interface into promiscuous mode
tcpdump --printPrint parsed packet output, even if the raw packets are being saved to a file with the -w
tcpdump --print-sampling=nthPrint every nth packet
tcpdump -Q direction --direction=directionChoose send/receive direction direction for which packets should be captured
tcpdump -qQuick output
tcpdump -r fileRead packets from file (which was created with the -w option or by other tools that write
tcpdump -S --absolute-tcp-sequence-numbersPrint absolute, rather than relative, TCP sequence numbers
tcpdump -s snaplen --snapshot-length=snaplenSnarf snaplen bytes of data from each packet rather than the default of 262144 bytes
tcpdump --skip countSkip count packets before writing or printing
tcpdump -T typeForce packets selected by "expression" to be interpreted the specified type
tcpdump -ttPrint the timestamp, as seconds since January 1, 1970, 00:00:00, UTC, and fractions of a s
tcpdump -tttPrint a delta (microsecond or nanosecond resolution depending on the --time-stamp-precisio
tcpdump -ttttPrint a timestamp, as hours, minutes, seconds, and fractions of a second since midnight, p
tcpdump -tttttPrint a delta (microsecond or nanosecond resolution depending on the --time-stamp-precision option)
tcpdump -U --packet-bufferedIf the -w option is not specified, or if it is specified but the --print flag is also spec
tcpdump -vWhen parsing and printing, produce (slightly more) verbose output
tcpdump -vvEven more verbose output
tcpdump -vvvEven more verbose output
tcpdump -V fileRead a list of filenames from file
tcpdump -w fileWrite the raw packets to file rather than parsing and printing them out
tcpdump -W filecountUsed in conjunction with the -C option, this will limit the number of files created
tcpdump -xWhen parsing and printing, in addition to printing the headers of each packet, print the d
tcpdump -xxWhen parsing and printing, in addition to printing the headers of each packet, print the d
tcpdump -XWhen parsing and printing, in addition to printing the headers of each packet, print the d
tcpdump -XXWhen parsing and printing, in addition to printing the headers of each packet, print the d
tcpdump -y datalinktype --linktype=datalinktypeSet the data link type to use while capturing packets (see -L) or just compiling and dumpi
tcpdump -z postrotate-commandUsed in conjunction with the -C or -G options, this will make tcpdump run " postrotate-com
tcpdump -Z user --relinquish-privileges=userIf tcpdump is running as root, after opening the capture device or input savefile, but bef
📄 View Printable Cheat Sheet — Download as PDF or print · 🧩 Combine with other tools

Related Shortcut Pages

ss / netstat Nmap Wireshark Filters Nginx Docker Bash / Shell

Search 18,500+ shortcuts across 268 platforms

Explore All Platforms Practice Shortcuts
📜 Every shortcut on this page is taken from the official tcpdump documentation — man7.org
🔧 Spotted an error or a missing shortcut? Suggest an edit on GitHub — every accepted fix goes live on this page, the API and the CLI.

The capture you run first

sudo tcpdump -i eth0 -nn port 443 is the shape of most captures: an interface, no name resolution, a filter. tcpdump -i interface --interface=interface picks the interface (any captures all of them, at the cost of link-layer headers), and tcpdump -D --list-interfaces lists what is available. tcpdump -n disables DNS lookups, and doubling it (-nn) also stops translating port numbers into service names — without them, a busy capture stalls on reverse lookups and the output changes shape. tcpdump -c count stops after a number of packets, which prevents an unbounded capture on a production host.

Writing files instead of reading the screen

tcpdump -w file writes raw packets to a pcap file and prints nothing, and tcpdump -r file reads one back with a filter applied, so a large capture can be sliced after the fact. For long captures, tcpdump -C file_size rotates files at a size in millions of bytes and tcpdump -G rotate_seconds rotates on time, with tcpdump -W filecount capping how many files are kept. tcpdump -s snaplen --snapshot-length=snaplen limits how many bytes of each packet are saved; the modern default captures full packets, and -s 96 is the old trick for headers only.

Reading the output

tcpdump -v, tcpdump -vv and tcpdump -vvv add protocol detail such as TTL, IP ID and checksum results. tcpdump -A prints packet payloads as ASCII, which makes unencrypted HTTP readable, and tcpdump -X prints hex and ASCII side by side. tcpdump -e adds the link-layer header with MAC addresses, needed for ARP and VLAN problems, and tcpdump -tttt prints full timestamps with the date. tcpdump -d dumps the compiled filter, which is how you check that a complicated expression means what you think.

Frequently asked questions

Why is tcpdump slow to print anything?

It is resolving hostnames and service names. Add -nn to disable both lookups.

How do I capture to a file for Wireshark?

tcpdump -i eth0 -w capture.pcap with a filter. Open the file in Wireshark, or read it back with tcpdump -r.

How do I capture only the packet headers?

Use -s with a small snapshot length, such as -s 96. The default captures whole packets.

How do I keep a long capture from filling the disk?

Combine -w with -C (rotate by size) or -G (rotate by seconds) and -W to limit the number of files kept, or use -c to stop after N packets.

🤖 Ask AI about tcpdump shortcuts

Open your assistant with this page preloaded as the source — great for follow-up questions like "which of these work in other apps?"

ChatGPT Claude Perplexity Gemini Grok