Ad Space — Top Banner

sudo: command not found

Linux Linux

Severity: Moderate

What Does This Error Mean?

The 'sudo: command not found' error means sudo is either not installed on your system, or your user account is not in the sudoers group. sudo is the tool that lets regular users run commands as the administrator. This error is common on fresh Debian installations and minimal server setups where sudo is not installed by default.

Affected Models

  • Debian
  • Ubuntu Server
  • CentOS
  • Arch Linux
  • Fedora Server
  • openSUSE

Common Causes

  • sudo is not installed — this is the default on Debian minimal and some server images
  • Your user account is not listed in the /etc/sudoers file or the sudo group
  • The sudo binary is installed but not in your PATH environment variable
  • You are logged in as root directly, and root does not need sudo
  • A minimal installation was used that excluded sudo to reduce the software footprint

How to Fix It

  1. Switch to the root user. If sudo is not installed, use the root account directly. Type: su - and enter the root password. You are now root and can run commands without sudo.

    The root password is set during installation. If you are on Debian and do not know it, check the documentation for your system.

  2. Install sudo. As root, run: apt install sudo (Debian/Ubuntu) or: dnf install sudo (Fedora) or: pacman -S sudo (Arch Linux).

    Most desktop Linux installations include sudo by default. Server and minimal installations often do not.

  3. Add your user to the sudo group. As root, run: usermod -aG sudo [yourusername] (Debian/Ubuntu) or: usermod -aG wheel [yourusername] (Fedora/CentOS/Arch).

    The sudo group on Debian/Ubuntu and the wheel group on Red Hat-based systems both grant sudo access. Log out and back in after this command.

  4. Verify your group membership. Run: groups [yourusername] to confirm you are now in the sudo or wheel group. Changes take effect on the next login.

    You must log out and log back in for group changes to take effect. Running 'newgrp sudo' in your current session is a shortcut that avoids a full logout.

  5. Check the PATH if sudo is installed but not found. Run: echo $PATH and look for /usr/bin in the output. If it is missing, run: export PATH=$PATH:/usr/bin and add that line to ~/.bashrc.

    In rare cases, the PATH variable is stripped down and does not include the directory where sudo lives.

When to Call a Professional

This error is entirely fixable at home. You need either root access or the ability to su to root to install sudo or add yourself to the sudo group. If you are locked out of root access as well, you will need to boot from a live USB to recover.

Frequently Asked Questions

What is the difference between sudo and su?

su switches you to another user account — usually root. You need to know that user's password. sudo runs a single command as another user (usually root) using your own password. Sudo is safer because it logs which commands were run, requires your own password, and can be configured to allow only specific commands.

Is it safe to run Linux as root all the time to avoid this error?

No — running as root all the time is very dangerous. Any mistake you make, or any program that gets compromised, has full power over your entire system. Linux's user permission system exists to protect you from accidental damage and malware. Use sudo for specific commands that need it, not as your daily user account.

How do I give sudo access to someone else on my Linux system?

As root or an existing sudo user, run: sudo usermod -aG sudo [theirusername]. They will need to log out and back in for the change to take effect. To give limited sudo access (only specific commands), edit /etc/sudoers using the visudo command.