You paste a command from a tutorial into a fresh server and the shell answers with a sudo command not found error. Nothing is broken.
Quick Answer: The shell can't find the sudo program, usually because a minimal image never installed it. If your prompt ends in
#, you're already root: run the command withoutsudo. Otherwise switch to root withsu -, runapt update && apt install sudo, add yourself withusermod -aG sudo yourname, then log in again. As of October 2026 this works on Debian 13 and Ubuntu 26.04.
Last verified: October 2026, against Debian 13.6 (trixie), Ubuntu 26.04 LTS (sudo-rs is the default sudo) and the current su manual page.
Our team resolves 20 to 30 client server issues every day, and this one nearly always turns up on brand-new machines, minutes after the first login. What follows is the walkthrough our engineers use, written so you can clear it yourself in about 5 minutes.
What the Sudo Command Not Found Error Means
It means your shell searched every directory in PATH and found no program called sudo. That points to a missing package or a damaged search path. Your password, your permissions and the server itself are fine.
Read the exact wording first, because three messages look alike:
| What the terminal prints | What it means | What to do |
|---|---|---|
bash: sudo: command not found | sudo itself is missing | Follow the fixes below |
sudo: ufw: command not found | sudo works, the program after it is missing | Install that program |
user is not in the sudoers file | sudo works, your account isn't allowed | Add your user to the admin group |
For the third one, our guide to the user is not in the sudoers file error is the right page.
On Debian, sudo is an optional package. As of October 2026, the Debian 13 installer adds it only when you leave the root password blank, as the Debian wiki page on sudo documents. Set a root password and you get a working root account, no sudo, and a first user outside the sudo group. Server templates copy that setup, which is why sudo missing on a VPS image is so common.
Why Sudo Is Missing: 5 Causes Ranked by Frequency
Sudo goes missing for five reasons, and a stripped-down operating system image is behind most of them. Three commands tell you which one you have.
Across the 4,000+ site migrations Hostaccent has handled since 2016, our engineers run the same check before changing anything on an unfamiliar server. We call it the 3-Line Sudo Triage, and it takes under 60 seconds:
bashwhoami # root, or a normal user? command -v sudo # prints a path if sudo is on your PATH ls -l /usr/bin/sudo # does the binary exist at all?
Match the output to the table, ordered by how often we see each cause:
| # | Cause | Where it shows up | Triage result |
|---|---|---|---|
| 1 | Minimal image, logged in as root | Debian server templates | root, no binary |
| 2 | Debian installed with a root password | netinst and ISO installs | Normal user, no binary |
| 3 | Container base image | Docker, LXC | root, no binary |
| 4 | Broken PATH | After editing .bashrc | Binary exists, command -v is silent |
| 5 | sudo not installed any more | Package clean-ups | No binary |
From the ticket queue: According to Hostaccent's support-queue data (October 2026), Linux server issues make up about 25% of monthly tickets. In our experience, the sudo cases inside that share are almost never faults. They are a bare OS template doing exactly what it was built to do: boot, and nothing more.
How to Fix It: Become Root and Install Sudo
To restore sudo on Debian 13 or Ubuntu as of October 2026, open a root shell with su -, run apt update && apt install sudo, then run usermod -aG sudo yourname and log in again. The whole job takes about 5 minutes and needs no reboot. Websites, databases and SSL certificates on the server keep running throughout.
Am I already root, so I don't even need sudo?
Quite possibly. If whoami prints root, or your prompt ends in # rather than $, you already hold every privilege sudo would grant. Delete the word: sudo apt install nginx becomes apt install nginx. To make tutorials work as written, run apt update && apt install -y sudo, then add a named user and grant sudo.
Install sudo on Debian minimal or netinst as a normal user
bashsu - apt update && apt install -y sudo usermod -aG sudo yourname exit
Enter the root password at the prompt, not your own. Then log out and back in, because group membership is read only at login.
Pro Tip: Type
su -, never plainsu. Since Debian 10, plainsukeeps your ownPATH, which leaves out/usr/sbin. You become root and install sudo without trouble, thenusermodanswers with its own "command not found". The hyphen starts a full login shell, as the su manual page describes.
On AlmaLinux, Rocky, RHEL and Fedora the command is dnf install sudo and the admin group is wheel. Alpine uses apk add sudo and Arch uses pacman -S sudo; on both, run visudo and uncomment the %wheel line. On Ubuntu 26.04, where sudo-rs is now the default according to the Ubuntu 26.04 LTS release notes, apt install sudo-rs restores it.
Docker containers
Containers run as root by default, so remove sudo from the command instead of installing it. If the image switches to an unprivileged user, open a root shell from the host with docker exec -u 0 -it container_name bash. An entrypoint script that calls sudo fails with exit code 127, one reason a Docker container keeps restarting.
The binary exists but the shell can't find it
bash/usr/bin/sudo whoami export PATH=/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin
If the first line prints root, sudo is healthy and your PATH is wrong. The second line repairs the current session. Then open ~/.bashrc and look for a line such as export PATH=$HOME/bin with no :$PATH on the end.
No root password and no sudo
This is the one awkward case: su - refuses you because the root account is locked. Boot into rescue mode from your provider's console, mount the disk, chroot into it and install the package there. If the password is simply lost, see how to change the root password in Linux.
Live server and no time for rescue mode? Our engineers fix this exact problem for a small one-time fee, and you see the exact quote before anyone touches the machine. Hosted with Hostaccent? Then it's simply covered by support, free. Have an engineer fix it
Still working through this server issue?
Send the symptoms, error output, and what you have already tried. We can work with Hostaccent services or infrastructure hosted with another provider.
Confirm the Fix and Stop It Coming Back
A sudo repair is confirmed when sudo whoami prints root from your normal account after a fresh login. Group changes made with usermod -aG apply only to new sessions, so a test in the same terminal fails even when the fix is correct. On Debian and Ubuntu, sudo then remembers your password for 15 minutes, so a second command won't prompt.
Did you edit the sudoers file along the way? Run visudo -c to check its syntax before you close your root session. The official sudo documentation covers every option.
Prevention is short. Make apt update && apt install -y sudo the first command on any new server, then create your named user (our walkthrough on how to set up a VPS has the full order). If you build servers with cloud-init, list sudo under packages:.
Insider Insight: A template that ships without sudo usually ships without other things too: no swap, no firewall, no automatic security updates. Spend 10 minutes checking those while you're logged in, starting with memory. Here's what to do when a VPS is running out of RAM.
The short version:
bash: sudo:means sudo is missing.sudo: something:means something else is.- Root never needs sudo. Drop the word.
- Use
su -with the hyphen, install, runusermod -aG, then log in again.
Your Next Step: A Server That's Ready on First Login
Fixed it? Now that you know a sudo command not found message is a missing package on a bare template, put that install line in your first-boot routine and you won't see it again. You could keep finishing empty images by hand, or run on a VPS where this class of problem is support's job. Hostaccent (hosting since 2016, UK-incorporated 2018) backs the Basic plan at $7.99/mo with 24/7 help from our own engineers and a 30-day money-back guarantee, and it renews at the same $7.99/mo. One honest caveat: it's a root-access server, so a control panel licence costs extra. Start on the Basic plan.
Still stuck? Open a ticket. It's a small one-time fee, quoted before any work starts.
Frequently Asked Questions
What does the bash sudo command not found error mean?
It means bash searched every directory in your PATH and found no executable named sudo. On a fresh Debian or minimal server image the package was never installed. Less often, a bad line in .bashrc has wiped the PATH. The message says nothing about your password or your permissions. Check with ls -l /usr/bin/sudo: if the file is absent, install the package as root, and if it's present, repair your PATH.
Why is sudo not installed on Debian by default?
Debian's installer treats sudo as optional. If you set a root password during installation, it assumes you'll administer the system as root, so it skips the package and leaves your first user out of the sudo group. Leave the root password blank and the opposite happens: root is locked, sudo is installed and your user gets admin rights. This behaviour is unchanged in Debian 13, the current stable release in October 2026.
How do I install sudo without sudo?
Use the root account directly. Run su - and enter the root password, then apt update && apt install sudo on Debian or Ubuntu, or dnf install sudo on AlmaLinux and Rocky. If you logged in over SSH as root, skip su - because you're already there. With no root password at all, boot into your provider's rescue mode, chroot into the installed system and install the package from that shell.
Why do I get command not found for usermod after switching to root?
You used plain su instead of su -. Since Debian 10, plain su keeps the calling user's PATH, and a normal user's PATH doesn't include /usr/sbin, where usermod, adduser and reboot live. The commands exist, but the shell isn't looking there. Type exit, then su - to start a proper root login shell, and run it again. As a one-off you can also call /usr/sbin/usermod by its full path.
Should I install sudo inside a Docker container?
Usually not. Containers run as root unless the image says otherwise, so the cleaner fix is to remove sudo from the command or the script. Installing it adds a setuid binary and extra image size for no benefit. If the image runs as an unprivileged user, switch with USER root in the Dockerfile for the install steps, then switch back, or open a root shell from the host using docker exec -u 0.












Discussion
Have a question or tip about this topic? Share it below — your comment will appear after review.