How to Fix bash strace command not found in Minimal Linux

The error message “bash: strace: command not found” surfaces in Linux terminal sessions when administrators attempt to trace system calls, process signals, and file descriptors on stripped-down server images, minimal container environments, or fresh cloud virtual machines. The strace diagnostic utility is excluded from base installations by default across enterprise distributions to minimise image footprint and reduce attack surfaces.

Install strace on Debian and Ubuntu Distributions

Debian-derived platforms package the system call tracer within the main universe repositories:

  1. Synchronise the local package index to retrieve the latest package metadata:
    sudo apt update
  2. Install the strace package binary:
    sudo apt install -y strace
  3. Verify the successful installation and confirm the binary path:
    which strace
    strace -V

Install strace on RHEL, CentOS, Rocky Linux, and Fedora

Red Hat Enterprise Linux derivatives maintain strace in their core system diagnostic streams:

  1. On systems running the DNF package manager (Fedora, RHEL 8/9, Rocky Linux, AlmaLinux):
    sudo dnf install -y strace
  2. On legacy CentOS 7 installations:
    sudo yum install -y strace
  3. Inspect available debugging symbol support by querying package details:
    rpm -qi strace

Install strace in Alpine Linux Docker Containers

Alpine Linux container images omit non-essential debugging utilities to maintain minimal image footprints:

  1. Update the Alpine package repository cache:
    apk update
  2. Install strace into the ephemeral container environment:
    apk add strace
  3. If deploying via a Dockerfile, include the utility during the build stage:
    RUN apk add --no-cache strace

Enable ptrace Capabilities in Docker and Kubernetes Environments

Containerised environments require administrative permissions to allow strace to inspect process memory and system calls:

  1. When launching a standalone Docker container, grant the SYS_PTRACE capability:
    docker run --cap-add=SYS_PTRACE -it ubuntu:latest bash
  2. Alternatively, launch the container in unconfined security mode for deep process debugging:
    docker run --security-opt seccomp=unconfined -it debian:latest bash
  3. In Kubernetes pod manifests, add the capability under the securityContext block:
    securityContext:
      capabilities:
        add:
          - SYS_PTRACE

Installing the strace package and configuring requisite kernel tracing privileges restores deep system call observability across minimal Linux installations.

Get the best tech tips delivered straight to your inbox.

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