Ubuntu: Headless wireshark (or wireshark from terminal)
Recently, we wanted to use wireshark on an Ubuntu through ssh and no X-Server forwarding enabled.
After a quick search we found tshark.
TSharkis a network protocol analyzer. It lets you capture packet data from a live network, or read packets from a previously saved capture file, either printing a decoded form of those packets to the standard output or writing the packets to a file.TShark‘s native capture file format ispcapformat, which is also the format used bytcpdumpand various other tools.
Without any options set,TSharkwill work much liketcpdump. It will use thepcaplibrary to capture traffic from the first available network interface and displays a summary line onstdoutfor each received packet.
TSharkis able to detect, read and write the same capture files that are supported byWireshark.From: man tshark
Install tshark on Ubuntu
sudo apt-get install tshark -y;
Using tshark to capture all traffic on eth0 to a pcap file
sudo tshark -i eth0 -w something.pcap;
Note: If you just want to capture network traffic on a network interface and not use the additional features wireshark has to offer, you can also use tcpdumpas follows
#The following command will create a files that has in its name the current date and time using the date function. sudo tcpdump -i eth0 -w "data.`date +%Y-%m-%d\ %H.%M`.pcap";


