Permissions

sudo: command not found

Fix for Debian, Docker, minimal VPS installs — updated May 2026

🐧 Debian 🐳 Docker ☁️ VPS 🐧 Ubuntu minimal
$ sudo apt update
bash: sudo: command not found

# or:
command not found: sudo

⚡ Quick Fix — Install sudo (as root)

# Switch to root first (if you have root access) su - # Install sudo apt-get install -y sudo # Add your user to the sudo group usermod -aG sudo yourusername # Log out and back in, then test sudo whoami

Why Does This Happen?

This error means the sudo binary is not installed on your system. This is most common on:

Fix on Debian / Ubuntu VPS

If you can log in as root (e.g. via SSH as root@yourserver):

# As root: apt-get update apt-get install -y sudo # Add your non-root user (replace 'deploy' with your username) usermod -aG sudo deploy # Apply group changes without logout (or just re-login) newgrp sudo

Fix in Docker Containers

In most Docker containers you run as root already — you don't need sudo. If a script requires it, install it in your Dockerfile:

FROM debian:bookworm-slim RUN apt-get update && apt-get install -y sudo && rm -rf /var/lib/apt/lists/* # Or just remove 'sudo' from the command you're running — you're already root

User Exists But Has No sudo Permission

If sudo is installed but your user account gets is not in the sudoers file:

# As root, add user to sudo group: usermod -aG sudo yourusername # Or edit sudoers directly (safer with visudo): visudo # Add this line: yourusername ALL=(ALL:ALL) ALL