The tcpflow utility captures network packet streams and reassembles them into complete, continuous data flows stored in human-readable files. Unlike tcpdump, which displays raw packet headers, tcpflow reconstructs actual bidirectional conversations (such as HTTP sessions or SMTP dialogues). In stripped container images and minimal cloud instances, running the command returns bash: tcpflow: command not found.
Install tcpflow via Standard Distribution Package Repositories
Installing tcpflow is supported directly across all major distribution package managers.
- On Ubuntu, Debian, Linux Mint, and derivatives:
sudo apt update && sudo apt install -y tcpflow - On Rocky Linux, AlmaLinux, CentOS, RHEL, and Fedora:
sudo dnf install -y epel-release && sudo dnf install -y tcpflow - On Alpine Linux (minimal Docker containers):
apk update && apk add tcpflow - On Arch Linux:
sudo pacman -Sy tcpflow
Grant Raw Packet Capture Permissions to Non-Root Users
Because tcpflow captures raw network traffic using libpcap, non-root users require explicit packet capture capabilities.
- Execute tcpflow with root privileges:
sudo tcpflow -i eth0 port 80. - Alternatively, assign raw packet capture capabilities:
sudo setcap 'cap_net_raw,cap_net_admin+ep' $(which tcpflow) - Verify that your active interface (e.g.
eth0orenp3s0) is specified using the-iflag.
Execute Stream Reconstruction and Replay Analysis
Capture and inspect complete application-layer flows in a dedicated diagnostic directory.
- Create and enter a temporary diagnostic folder:
mkdir /tmp/tcpflow_test && cd /tmp/tcpflow_test - Capture traffic on port 80:
sudo tcpflow -i eth0 port 80 - Inspect generated flow files containing reconstructed HTTP conversations:
ls -la && cat *