LinuxCommandLibrary
GitHubF-DroidGoogle Play Store

tshark

Command-line network packet analyzer

TLDR

Monitor everything on localhost
$ tshark
copy
Only capture packets matching a capture filter
$ tshark -f 'udp port 53'
copy
Only show packets matching an output filter
$ tshark -Y 'http.request.method == "GET"'
copy
Decode a TCP port using a specific protocol
$ tshark -d tcp.port==8888,http
copy
Specify the format of captured output
$ tshark -T [json|text|ps]
copy
Select specific fields to output
$ tshark -T fields -e http.request.method -e ip.src
copy
Write captured packets to a file
$ tshark -w [path/to/file]
copy
Analyze packets from a file
$ tshark -r [path/to/file.pcap]
copy

SYNOPSIS

tshark [options] [filter]

DESCRIPTION

tshark is the command-line version of Wireshark, providing network packet capture and analysis capabilities. It can capture live traffic from network interfaces, read packets from capture files, and decode protocol data.The tool supports both capture filters (BPF syntax, applied during capture) and display filters (Wireshark syntax, applied to output). It can output data in various formats including text, JSON, and PDML for further processing.

PARAMETERS

-i interface

Capture on specified interface
-f filter
Capture filter (BPF syntax)
-Y filter
Display filter (Wireshark syntax)
-r file
Read packets from file
-w file
Write packets to file
-T format
Output format (text, json, pdml, ps, fields, etc.)
-e field
Field to print (with -T fields/json/pdml)
-d spec
Decode as protocol (e.g., tcp.port==8080,http)
-c count
Stop after capturing count packets
-a condition
Autostop condition (duration:sec, filesize:KB)
-V
Verbose output (packet tree)
-x
Print hex dump of packet data
-q
Quiet mode (less output)

INSTALL

sudo apt install tshark
copy
sudo apk add tshark
copy
nix profile install nixpkgs#tshark
copy

CAVEATS

Requires root or appropriate capabilities for live capture. Capture and display filter syntaxes are different. Large captures can consume significant disk space and memory. Some protocol decoding requires port hints via -d option.

HISTORY

Part of the Wireshark project, originally called Ethereal. The command-line version has been available since the early days of the project. tshark provides the same protocol analysis engine as Wireshark but suited for scripting and headless systems.

SEE ALSO

Braincup
Open source brain training for math, memory and focus
Braincup mini-games
41 mini-games · Apache-2.0
No ads · No tracking
Play in browser
Download Braincup on the App StoreGet Braincup on Google PlayGet Braincup on F-Droid
276 stars
From the maker of Linux Command Library
Copied to clipboard
Braincup
Open source brain training for math, memory and focus. 41 mini-games, from mental arithmetic to Sudoku, N-Back and Solo Chess.
Apache-2.0 licensed · No ads · No tracking · No account
From the maker of Linux Command Library
Download Braincup on the App StoreGet Braincup on Google PlayGet Braincup on F-Droid