As a Linux system administrator, understanding what happens on your network is crucial. One of the most powerful tools to monitor network traffic directly from the command line is tcpdump
. Itās lightweight, pre-installed on many distros, and extremely versatile for capturing and analyzing packets.
In this guide, weāll walk through what tcpdump
is, how to use it, and practical examples tailored for beginner sysadmins.
tcpdump
?tcpdump
is a command-line packet analyzer. It allows you to capture and display network packets transmitted over a network interface. It works by using the libpcap
library to sniff and filter traffic.
Itās like a real-time log of the conversations your server is having on the network ā and youāre invited to listen in.
tcpdump
On most distributions, itās available via the default package manager:
bashCopyEdit# Debian/Ubuntu
sudo apt install tcpdump
# RHEL/CentOS/AlmaLinux
sudo dnf install tcpdump
# Arch Linux
sudo pacman -S tcpdump
You can verify installation with:
bashCopyEdittcpdump --version
To capture packets on your default network interface:
bashCopyEditsudo tcpdump
Youāll see a flood of real-time traffic. Use Ctrl + C
to stop capturing.
To list available interfaces:
bashCopyEdittcpdump -D
To capture on a specific one:
bashCopyEditsudo tcpdump -i eth0
sudo tcpdump tcp
sudo tcpdump udp
sudo tcpdump icmp
sudo tcpdump host 192.168.1.100
sudo tcpdump dst port 80
sudo tcpdump port 22
You can save output to a .pcap
file for later analysis with tools like Wireshark:
bashCopyEditsudo tcpdump -i eth0 -w capture.pcap
To read the file:
bashCopyEditsudo tcpdump -r capture.pcap
Use the -c
option to avoid overwhelming output:
bashCopyEditsudo tcpdump -c 10
To make packet contents easier to understand:
bashCopyEditsudo tcpdump -n -v
-n
: Donāt resolve hostnames.-v
: Verbose output (use -vv
or -vvv
for more detail).bashCopyEditsudo tcpdump -i eth0 dst port 80
bashCopyEditsudo tcpdump -i eth0 port 22
bashCopyEditsudo tcpdump -i eth0 host 10.0.0.50
tcpdump
with sudo
to access network interfaces.tcpdump
running unattended ā it can quickly consume disk space.screen
or tmux
if running remotely.tcpdump
is an essential tool in every Linux sysadminās toolkit. Whether youāre diagnosing a network issue, checking for suspicious traffic, or just learning how networking works ā itās a great place to start.
As you grow, you can combine tcpdump
with tools like awk
, grep
, or Wireshark
to do even deeper analysis.
If you manage Linux servers regularly, you know how important SSH (Secure Shell) is. Whether…
If youāre new to Linux or thinking about switching from Windows or macOS, this guide…
Introduction Site Reliability Engineering (SRE) has become a critical discipline in modern IT operations. The…
Updated: August 17, 2025 A practical guide to the best free CRM (Customer Relationship Management)…
If you run a VPS or dedicated server with Linux, you probably know that managing…
Short summary: Use built-in Linux tools (`who`, `last`, `journalctl`, `/var/log/auth.log`) and optional audit logs to…
This website uses cookies.