September 23, 2023

Resolving the ‘sudo’: command not found’ Error in Linux

Sanjana Kumari

Have you ever encountered the frustrating ‘sudo: command not found’ error while working in a Linux environment? If you’re a Linux user, this error can be a real roadblock to your productivity. In this article, we will delve into the causes of this error and provide you with effective solutions to resolve it. So, let’s get started and get your Linux system back on track.

Understanding the ‘sudo’ Command

Before we dive into the troubleshooting process, let’s first understand what the ‘sudo’ command is and why it’s essential in a Linux system. The term ‘sudo’ stands for “superuser do,” and it allows authorized users to execute commands with superuser privileges. This means you can perform critical system operations without needing to log in as the root user.

Common Causes of ‘sudo: command not found’ Error

Lack of sudo Installation

One of the most common reasons for encountering the ‘sudo: command not found’ error is the absence of the ‘sudo’ package on your system. In some Linux distributions, ‘sudo’ might not be pre-installed, so you’ll need to install it manually.

Incorrect System Configurations

Incorrect system configurations, such as misconfigured PATH variables, can lead to the ‘sudo’ command not being recognized. This can happen when system files or directories are moved, renamed, or deleted.

Environment Variables Issues

Sometimes, issues with environment variables, such as PATH, can result in the ‘sudo: command not found’ error. The system may not be able to locate the ‘sudo’ binary due to these variable problems.

ALSO READ :  Windows or Linux can be used to host a Project Dedicated Server

User Permissions and PATH Settings

User permissions and PATH settings can also play a role in this error. If your user doesn’t have the necessary permissions to run ‘sudo’ or if the PATH is not correctly set up, you might face this issue.

Troubleshooting and Resolving the Error

Now that we’ve identified the common causes, let’s move on to troubleshooting and resolving the ‘sudo: command not found’ error on your Linux system.

Verifying sudo Installation

Begin by checking if ‘sudo’ is installed on your system. Open a terminal and type:

sudo -v

If ‘sudo’ is installed, this command will ask for your password. If it’s not installed, you’ll receive an error message, and you’ll need to install it using your package manager.

Checking System PATH Variables

Verify that your PATH variable is correctly configured. You can do this by echoing the PATH variable in your terminal

echo $PATH

Ensure that the directory containing ‘sudo’ is included in the PATH.

Editing sudoers File

The sudoers file, located at ‘/etc/sudoers’, controls who can run ‘sudo’ and what commands they can run. Make sure your user is listed in this file and has the appropriate permissions. You can edit it using the ‘visudo’ command:

sudo visudo

Resetting User Permissions

If you suspect user permission issues, you can reset them by running:

sudo chmod u+s /usr/bin/sudo

This command ensures that ‘sudo’ runs with the necessary permissions.

Fixing Environment Variables

To address environment variables issues, review your shell configuration files like ‘.bashrc’ or ‘.zshrc’ for any incorrect PATH assignments or other problems.

Simplest Method for Resolving the Sudo Command Not Found Error.

Let’s go through this tutorial and find the simple solution to fix sudo command not found, once forever. You must log out of your user account and log in as root because your user cannot take on the rights of the root user unless sudo is already installed. You can install the sudo package as the root user using the permissions that this account has.

To log into your system, run the command below as the root user:

$ sudo su -

You can also switch to the root user. Now, you can update the package lists and install the sudo package. So, simply run:

# apt update -y
# apt install sudo -y

To install sudo on CentOS Stream, Fedora, Rocky Linux, or Alma Linux, use the following command to switch to the root user and then, install sudo:

# su -
# yum install sudo

To install sudo on Arch Linux, type:

# pacman -Sy sudo

On Debian-based systems, enter:

apt install sudo

To give all the sudo permissions, run:

$ user od -AG <username>

Then, you can check the permissions by opening the ‘sudoers’ file:

$ nano /etc/sudoers

Now, you should be able to use sudo to execute all the commands

Preventing Future Occurrences

To prevent encountering the ‘sudo: command not found’ error in the future, consider implementing the following best practices:

  • Regularly update your system and packages.
  • Keep a backup of your important system files.
  • Create aliases for frequently used commands to avoid typos and PATH issues.

Alternative Solutions

If you’re still struggling to resolve the issue or prefer alternative methods, here are some options:

Utilizing the ‘su’ Command

Instead of ‘sudo,’ you can use the ‘su’ (switch user) command to temporarily become the root user and execute commands. Be cautious when using ‘su’ as it grants unrestricted access.

Creating a Root User

Another approach is to create a root user if it doesn’t exist and use it when needed. However, exercise caution as this gives you constant superuser access.

Seeking Help from the Linux Community

If all else fails, don’t hesitate to seek assistance from the vast Linux community. Online forums, documentation, and fellow Linux users can provide valuable insights and solutions.

ALSO READ : How to Restrict Internet Access for Programs in CentOS 7


In this article, we’ve explored the ‘sudo: command not found’ error, its common causes, and effective troubleshooting steps to resolve it. Linux users rely heavily on the ‘sudo’ command for system management, so resolving this error promptly is crucial. By following the provided solutions and best practices, you can ensure a smooth and error-free Linux experience.


1. What is the ‘sudo’ command in Linux? The ‘sudo’ command stands for “superuser do” and allows authorized users to execute commands with superuser privileges, enhancing system security.

2. Why does the ‘sudo: command not found’ error occur? This error can occur due to reasons such as the absence of ‘sudo’ installation, incorrect system configurations, environment variables issues, and user permissions and PATH settings.

3. How can I check if ‘sudo’ is installed on my Linux system? You can check by running the command ‘sudo -v’ in your terminal. If ‘sudo’ is installed, it will ask for your password; otherwise, you’ll receive an error.

Popular Blog Posts