tcpdump Command in Linux with Examples
tcpdump is a packet sniffing and packet analyzing tool for a System Administrator to troubleshoot connectivity issues in Linux. It is used to capture, filter, and analyze network traffic such as TCP/IP packets going through your system. It is many times used as a security tool as well. It saves the captured information in a pcap file, these pcap files can then be opened through Wireshark or through the command tool itself.
Installing tcpdump tool in Linux
Many Operating Systems have tcpdump command pre-installed but to install it, use the following commands.
For RedHat based linux OS
yum install tcpdump
For Ubuntu/Debian OS
apt install tcpdump
Working with tcpdump command
1. To capture the packets of current network interface
sudo tcpdump

This will capture the packets from the current interface of the network through which the system is connected to the internet.
2. To capture packets from a specific network interface
sudo tcpdump -i wlo1

This command will now capture the packets from wlo1 network interface.
3. To capture specific number of packets
sudo tcpdump -c 4 -i wlo1

This command will capture only 4 packets from the wlo1 interface.
4. To print captured packages in ASCII format
sudo tcpdump -A -i wlo1

This command will now print the captured packets from wlo1 to ASCII value.
5. To display all available interfaces
sudo tcpdump -D

This command will display all the interfaces that are available in the system.
6. To display packets in HEX and ASCII values
sudo tcpdump -XX -i wlo1


This command will now print the packages captured from the wlo1 interface in the HEX and ASCII values.
7. To save captured packets into a file
sudo tcpdump -w captured_packets.pcap -i wlo1

This command will now output all the captures packets in a file named as captured_packets.pcap.
8. To read captured packets from a file
sudo tcpdump -r captured_packets.pcap

This command will now read the captured packets from the captured_packets.pcap file.
9. To capture packets with ip address
sudo tcpdump -n -i wlo1

This command will now capture the packets with IP addresses.
10. To capture only TCP packets
sudo tcpdump -i wlo1 tcp

This command will now capture only TCP packets from wlo1.
Recommended Posts:
- rcp Command in Linux with examples
- apt-get command in Linux with Examples
- until command in Linux with Examples
- last command in Linux with Examples
- mv command in Linux with examples
- look command in Linux with Examples
- help Command in Linux with examples
- more command in Linux with Examples
- ps command in Linux with Examples
- fc Command in Linux with Examples
- if command in linux with examples
- apt command in linux with examples
- less command in Linux with Examples
- dig Command in Linux with Examples
- env command in Linux with Examples
- dir command in Linux with examples
- Cat command in Linux with examples
- rev command in Linux with Examples
- seq command in Linux with Examples
- id command in Linux with examples
If you like GeeksforGeeks and would like to contribute, you can also write an article using contribute.geeksforgeeks.org or mail your article to contribute@geeksforgeeks.org. See your article appearing on the GeeksforGeeks main page and help other Geeks.
Please Improve this article if you find anything incorrect by clicking on the "Improve Article" button below.


