How to Fix bash tcpreplay Command Not Found in Minimal Linux

Network engineers, cybersecurity analysts, and system administrators routinely rely on the tcpreplay suite to replay captured PCAP packet traces through physical and virtual network interfaces for performance benchmarking and firewall validation. On newly provisioned minimal Linux installations, lightweight container images (such as Alpine, Ubuntu Minimal, or Rocky Linux Base), attempting to run the command generates the error: bash: tcpreplay: command not found. This occurs because minimal systems exclude packet injection and raw socket utilities by default.

Install tcpreplay on Ubuntu, Debian, and Linux Mint

On Debian-based distributions, the tcpreplay binary is available directly through the primary universe and main package repositories:

  1. Update your local package index to ensure repository metadata is fresh:
    sudo apt update
  2. Install the complete tcpreplay toolkit:
    sudo apt install -y tcpreplay
  3. Confirm successful installation by checking the compiled version and supported packet engine:
    tcpreplay --version

Install tcpreplay on RHEL, CentOS Stream, Rocky Linux, and Fedora

Enterprise Linux distributions host tcpreplay within the Extra Packages for Enterprise Linux (EPEL) repository. You must enable EPEL before invoking the package manager:

  1. Enable the EPEL repository (on RHEL, AlmaLinux, or Rocky Linux):
    sudo dnf install -y epel-release
  2. Refresh repository caches:
    sudo dnf makecache
  3. Install the package:
    sudo dnf install -y tcpreplay
  4. On Fedora systems where EPEL is built-in, execute:
    sudo dnf install -y tcpreplay

Install tcpreplay on Alpine Linux Docker Containers

Minimal container environments operating Alpine Linux utilize apk to retrieve security and network utilities:

  1. Update the package index:
    apk update
  2. Install the tcpreplay package from the community repository:
    apk add tcpreplay
  3. If raw socket injection permissions are required inside Docker, ensure the container was instantiated with the --cap-add=NET_RAW --cap-add=NET_ADMIN flags.

Install on Arch Linux and Manjaro

Arch Linux packages tcpreplay within the standard extra repository:

  1. Synchronize repository databases and install the package:
    sudo pacman -Sy tcpreplay
  2. Verify that supporting tools (including tcpprep, tcprewrite, and tcpbridge) are accessible in your active shell path:
    which tcpreplay tcprewrite tcpprep

Verify User PATH and Raw Socket Capabilities

If you compiled tcpreplay from source or installed it into an alternate directory such as /usr/local/bin, your shell environment may fail to locate the binary if that path is omitted from $PATH:

  1. Inspect your current execution path:
    echo $PATH
  2. If /usr/local/bin is missing, append it to your environment by adding the following line to ~/.bashrc:
    export PATH=$PATH:/usr/local/bin
  3. Reload your shell configuration:
    source ~/.bashrc

Get the best tech tips delivered straight to your inbox.

Join thousands of readers mastering Apple, Google, Microsoft, and Linux.