tcpdump Command in Linux
Transform Your Career
Choose from our industry-leading programs designed for career success
Modern Software and AI Engineering Program
Master full-stack development with AI integration
+1000 moreModern Data Science and ML with specialisation in AI
Advanced data science techniques with AI specialization
+1000 moreAdvanced AIML with Specialisation in Agentic AI
Deep dive into AIML with focus on Agentic systems
+1000 moreDevOps, Cloud & AI Platform Engineering
Build and manage AI-powered cloud infrastructure
+1000 moreAI Engineering Advanced Certification by IIT-Roorkee
Premier AI engineering certification from IIT-Roorkee
Overview
tcpdump is a powerful command-line tool used by Linux administrators and network engineers to capture and analyze network traffic in real-time. It is an essential utility for troubleshooting network problems, monitoring network activity, and understanding how network protocols work.
Linux tcpdump Command Syntax
The syntax for the tcpdump command is as follows:
Where:
- options: These are flags and arguments that modify the behavior of tcpdump, such as filters, output formatting, and verbosity levels.
- expression: This is a filter expression used to capture specific packets based on criteria like source or destination IP address, port, protocol, and more.
tcpdump Command Options:
- -i: Specify the network interface to capture packets from.
- -n: Display IP addresses and port numbers instead of hostnames and service names.
- -c: Capture a specified number of packets and then exit.
- -w: Save captured packets to a file instead of displaying them on the screen.
Example Usages
-
Capture all packets on the eth0 interface:
Output:
Explanation: This command captures all the packets on the eth0 interface and displays them on the screen.
-
Capture only ICMP packets:
Output:
Explanation: This command captures only ICMP packets and displays them on the screen.
Scaler Placement Report and Statistics
Scaler learners achieved 2.5x salary growth with average post-Scaler CTC reaching ₹23L.
Tips
-
Use the -D option to list available network interfaces.
-
Use the -X option to display packet contents in both hexadecimal and ASCII formats.
Advanced Use Cases of tcpdump Command in Linux
-
Capture packets between two specific IP addresses:
Output:
Explanation: This command captures packets exchanged between 192.168.1.1 and 192.168.1.2.
-
Capture packets with a specific port number:
Output:
Explanation: This command captures packets with a source or destination port number of 80.
-
Capture packets of a specific protocol:
Output:
Explanation: This command captures packets using the ICMP protocol.
Turn Learning into Career Growth
Conclusion
-
tcpdump is a powerful tool for capturing and analyzing network traffic.
-
The command supports various options and filters to target specific traffic.
-
It is an essential utility for network troubleshooting and monitoring.




