LinuxMedium

sudo: command not found — causes and solutions in Linux

The 'sudo: command not found' error means the system cannot locate the sudo executable. Learn why this happens (from missing package to PATH issues) and how to restore the command for administrative tasks.

Updated at February 17, 2026
5-10 min
Easy
FixPedia Team
Применимо к:Ubuntu 20.04/22.04/24.04Debian 11/12CentOS 7/8/Rocky 8/9sudo 1.8.x/1.9.x

What the sudo: command not found Error Means

The error sudo: command not found (or bash: sudo: command not found) appears in a Linux terminal when you try to run a command with sudo, but the system cannot find the sudo executable file in the directories listed in the PATH environment variable.

Typical output:

$ sudo apt update
bash: sudo: command not found

This means either the sudo package is not installed on your system, or the PATH variable is configured incorrectly, and the system does not search for executables in standard directories like /usr/bin or /bin.

Common Causes

  1. The sudo package is not installed. Some minimal or specialized Linux installations (e.g., certain containers, Docker images, or systems where the root user is used by default) may not include sudo in the base package set.
  2. Incorrect PATH variable. The PATH variable defines the list of directories where the system looks for executable commands. If the standard directory /usr/bin (where sudo usually resides) has been removed from PATH or PATH has been overridden incorrectly (e.g., in ~/.bashrc or ~/.profile), the command will not be found.
  3. Corruption or deletion of the sudo binary file. The file /usr/bin/sudo might have been accidentally deleted or corrupted due to a system update failure or manual intervention.

Solutions

Solution 1: Check and Fix the PATH Variable (Most Common Case)

This is the first thing to check. It's possible sudo is installed, but the system "doesn't see" it.

  1. Check your current PATH. Run:
    echo $PATH
    

    Note the list of directories separated by colons. The standard path for sudo is /usr/bin. Ensure this directory appears in the output. Example of a correct PATH:
    /usr/local/bin:/usr/bin:/bin:/usr/local/games:/usr/games
    
  2. Temporarily add /usr/bin to PATH for the current terminal session to immediately test if this resolves the issue:
    export PATH=$PATH:/usr/bin
    

    After this, try the sudo command again. If it works, the problem is definitely with PATH.
  3. Restore PATH permanently. Open your shell's configuration file. For bash, this is typically ~/.bashrc or ~/.profile.
    nano ~/.bashrc
    

    Find the line starting with PATH=. If it doesn't exist, add this to the end of the file:
    export PATH=$PATH:/usr/bin
    

    Important: Do not overwrite PATH completely (e.g., PATH=/usr/bin), but append to the existing value using $PATH:, or you will lose all other paths.
  4. Apply the changes. Save the file (Ctrl+O, Enter, Ctrl+X in nano) and run:
    source ~/.bashrc
    

    The sudo command should now work in the current terminal.

Solution 2: Install the sudo Package (If It's Missing)

If sudo is genuinely not installed, you need to install it. Since installing packages usually requires root privileges and you don't have sudo, you can:

  1. Log in as root (if you know the root password) using the su command:
    su -
    

    Enter the root password. You will then get a # prompt.
  2. Install sudo using your distribution's package manager:
    • For Debian/Ubuntu and derivatives:
      apt update
      apt install sudo
      
    • For RHEL/CentOS/Rocky/AlmaLinux:
      yum install sudo
      # or for newer versions
      dnf install sudo
      
    • For Arch Linux:
      pacman -S sudo
      
  3. Configure access for your user (if you are not already in the sudo or wheel group):
    • In Debian/Ubuntu, add the user to the sudo group:
      usermod -aG sudo your_username
      
    • In RHEL/CentOS, add the user to the wheel group:
      usermod -aG wheel your_username
      

    Replace your_username with your actual username.
  4. Log out of the root session (exit) and try using sudo again. You may need to log out of your system completely and log back in for the group changes to take effect.

Solution 3: Restore a Corrupted or Deleted Binary

If the file /usr/bin/sudo is missing or has incorrect permissions, the command will fail even with a correct PATH and an installed package.

  1. Check for the file and its permissions:
    ls -l /usr/bin/sudo
    

    Expected output (permissions may vary slightly):
    -rwsr-xr-x 1 root root 146736 Jan 15 2024 /usr/bin/sudo
    

    Note the s in the permissions (rws). This is the special SETUID bit, which allows the program to run as the owner (root). Its absence can cause issues, but not a "command not found" error.
  2. If the file is missing, reinstall the sudo package as described in Solution 2. This is the most reliable way to restore the original binary.
  3. If permissions are incorrect (e.g., no s or owner is not root), fix them after reinstalling:
    chmod 4755 /usr/bin/sudo
    chown root:root /usr/bin/sudo
    

Solution 4: Temporary Workaround — Use su

If you cannot fix sudo quickly but need to execute commands as root, use su (switch user).

  1. Switch to the root user:
    su -
    

    Enter the root password.
  2. Execute the necessary commands. Remember that working as root can accidentally damage your system. Try to fix sudo as soon as possible.
  3. Return to your user: run exit.

⚠️ Important: This is not a solution, just a temporary workaround. Working as root constantly is not secure.

Prevention

  • Do not remove system directories (/usr/bin, /bin, /sbin) from the PATH variable manually. If you need to add your own directory, append it using :.
  • When editing ~/.bashrc or ~/.profile be careful with the export PATH=... syntax. It's best to use the pattern export PATH=$PATH:/your/new/path.
  • Check compatibility of scripts and programs that might modify PATH (e.g., Python version managers like pyenv or Node.js nvm). Ensure they do not overwrite PATH completely.
  • Regularly update your system (sudo apt update && sudo apt upgrade or similar) to avoid package corruption.
  • When using Docker or chroot environments, explicitly install sudo if you plan to use it, as minimal images often do not include it.

F.A.Q.

Why did sudo suddenly stop working after a system update?
How to check if the sudo package is installed on the system?
What is the difference between `su` and `sudo`, and can I use `su` instead of `sudo`?
Can I completely disable sudo and work only as root?

Hints

Check for sudo and the PATH variable
Install or reinstall the sudo package
Fix the PATH variable in the shell configuration
Check sudo binary permissions
Reload the shell or system
FixPedia

Free encyclopedia for fixing errors. Step-by-step guides for Windows, Linux, macOS and more.

© 2026 FixPedia. All materials are available for free.

Made with for the community