Understanding the Error
sudo is not installed or not in PATH.
Fix 1: Install sudo (as root)
# For Debian/Ubuntu (as root)
apt update && apt install sudo -y
# For CentOS/RHEL (as root)
yum install sudo -y
# For Alpine (as root)
apk add sudo
Fix 2: Add User to sudoers
# As root
usermod -aG sudo username # Debian/Ubuntu
usermod -aG wheel username # CentOS/RHEL
# Verify
groups username
Fix 3: Fix PATH Environment
# Temporarily use full path
/usr/bin/sudo command
# Add to ~/.bashrc
export PATH=$PATH:/usr/bin:/usr/sbin
source ~/.bashrc
Fix 4: Run as Root Instead
If sudo not available:
su -
# Enter root password
# Then run commands without sudo
Fix 5: Minimal Docker Containers
Run as root inside container or use USER root in Dockerfile.
Fix 6: Check sudo Exists
which sudo
whereis sudo
find / -name sudo -type f 2>/dev/null
If not found, install from your distribution's package manager.