Sudo Command Not Found on Fresh Linux Install? Fix It Now

Linux & Unix Beginner 👁 10 views 📅 Jun 26, 2026

Sudo isn't installed by default on some Linux distros. Install it and add your user to the sudo group. Works on Ubuntu, Debian, Fedora, and Arch.

You just booted up your new Linux install, tried running sudo apt update or sudo pacman -Syu, and got hit with "sudo: command not found." That's frustrating, I get it. But don't worry — it's a simple fix. Let's get you sorted.

The Quick Fix: Install Sudo and Add Your User

First, you need to switch to the root user. You're probably already logged in as a regular user. Type this and press Enter:

su -

It'll ask for the root password — the one you set during installation. If you didn't set one (Ubuntu does this sometimes), you might be stuck. But most fresh installs have one. After typing it, your prompt should change to a # sign, meaning you're root now.

Now install sudo. The command depends on your distro. Here's what to run:

If you're on Ubuntu, Debian, Linux Mint, or Pop!_OS

apt update && apt install sudo -y

After running that, you should see a bunch of text scroll by, ending with "done" or "installed." That means sudo is installed.

If you're on Fedora, CentOS, RHEL, or Rocky Linux

dnf install sudo -y

Same deal — wait for it to finish. You'll see a message like "Complete!" when it's done.

If you're on Arch Linux, Manjaro, or EndeavourOS

pacman -S sudo --noconfirm

This should complete without errors. If it says "target not found," you might need to run pacman -Sy first to sync the package database. Try that, then run the install again.

Now Add Your User to the Sudo Group

Installing sudo isn't enough — you also need to give your regular user permission to use it. Still as root, run:

usermod -aG sudo your_username

Replace your_username with your actual username. For example, if your username is "john", it's usermod -aG sudo john.

On Fedora or CentOS, the group is often called wheel instead of sudo. In that case, run:

usermod -aG wheel your_username

After this, type exit to leave the root shell. You'll be back at your normal user prompt.

Now you need to log out and log back in for the group change to take effect. The easiest way is to close your terminal and open a new one. Or just run logout and log in again. After that, test it:

sudo whoami

If it asks for your password and shows root, you're all set. If it still says "sudo: command not found," go back and double-check step one — maybe the package didn't install.

Why This Happens on Fresh Installs

Some Linux distros keep things minimal. They install the absolute minimum to boot and run. Sudo is considered optional. For example, Debian's net install image doesn't include sudo by default. Same with some Arch-based distros. Ubuntu's desktop version usually includes sudo, but the server version might not. So don't blame yourself — it's by design.

Another reason: the user account created during installation might not have been added to the sudo group. Some installers add the first user to the sudo group automatically, but not all do. If you ticked the wrong box during setup, you're left without sudo access.

Less Common Variations of This Issue

Sometimes the problem isn't missing sudo — it's a broken PATH. If you installed sudo but it still says "command not found," check where sudo is located:

which sudo

If that returns nothing, sudo might be in /usr/local/bin or /usr/bin. Try running it with the full path:

/usr/bin/sudo whoami

If that works, your PATH variable is missing the directory where sudo lives. You can fix it temporarily by running:

export PATH=$PATH:/usr/bin

Then add that line to your ~/.bashrc file so it sticks after rebooting.

Another rare case: the sudo package is installed but the sudo group doesn't exist. This can happen on very minimal installs. As root, create the group:

groupadd sudo

Then add your user again with usermod -aG sudo your_username. Some distros like Arch use the wheel group instead, but creating sudo works fine too.

One more: on some older systems, sudo might be replaced by doas. If you see doas: command not found, install opendoas from your package manager. But that's rare on fresh installs of mainstream distros.

How to Avoid This Next Time

Before you install, check the distro's documentation. Most tell you if sudo is included. For example, Debian's net install guide says you need to install sudo manually. Ubuntu's server guide mentions it too.

During installation, look for a checkbox that says something like "Add user to sudo group" or "Give user administrator privileges." On Ubuntu's installer, it's under "Your name" settings — a toggle for "Admin" access. Click it.

If you're using a minimal install script or a custom ISO, add sudo to the package list before you start. For Arch, add sudo to your pacstrap command. For Debian, include it in your tasksel selection.

And if you're setting up a server, just install sudo right after the OS boots. It's the first thing I do with every fresh install. Takes 30 seconds and saves headache.

Was this solution helpful?