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:
- Synchronise the local package index to retrieve the latest package metadata:
sudo apt update - Install the strace package binary:
sudo apt install -y strace - 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:
- On systems running the DNF package manager (Fedora, RHEL 8/9, Rocky Linux, AlmaLinux):
sudo dnf install -y strace - On legacy CentOS 7 installations:
sudo yum install -y strace - 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:
- Update the Alpine package repository cache:
apk update - Install strace into the ephemeral container environment:
apk add strace - 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:
- When launching a standalone Docker container, grant the
SYS_PTRACEcapability:docker run --cap-add=SYS_PTRACE -it ubuntu:latest bash - Alternatively, launch the container in unconfined security mode for deep process debugging:
docker run --security-opt seccomp=unconfined -it debian:latest bash - In Kubernetes pod manifests, add the capability under the
securityContextblock:securityContext: capabilities: add: - SYS_PTRACE
Installing the strace package and configuring requisite kernel tracing privileges restores deep system call observability across minimal Linux installations.