monovm

Follow MonoVM
on social networks
and stay updated
with our new posts.

instagram twitter linkedin Youtube facebook telegram
English
+370 5 205 5502 sales@monovm.com

How to fix "Sudo Command not found error" on Linux?

When you work as a sudo user on Linux, Then you come across the sudo command not found error in front of your screen; This article will help you with its fix/solution

03 Feb, 22 by Susith Nonis 4 min Read

List of content you will read in this article:

In Linux and UNIX-like systems, the Sudo command executes a specific command with root privileges. The user who runs this command has complete access to the system and can modify or add anything.

If you are an experienced Linux user, you might have encountered the “sudo: command not found” error while setting up the Linux desktop or virtual machine. Though you may have the command installed, you may get this error message in rare cases. However, this error message can be intimidating and prevents you from proceeding further with the setup process. As a result, it becomes obligatory to fix this error message.

Fortunately, we have a simple solution to this problem. Let us explore the solution in this article. But before it, let us have a brief introduction to the Sudo command.

Sudo stands for “Super User Do” and is pronounced as “sue dough.” It is a command-line utility that is usually built-in for UNIX and Linux-based operating systems and grants users permission to execute different commands at the most potent level of the system, the root level. It is generally used as a prefix for many other Linux commands, and only superusers have permission to execute them.

This command is equivalent to the “Run as Administrator” in Windows. Sudo also keeps a log of all commands and arguments.

As there are several user accounts on the Linux system, many of them are assigned a set of privileges that do not have the right permissions to carry out administrative tasks. Also, users with limited privileges are not granted permission to access certain filesystem areas.

However, one user has the right to access any part or area of the system called the root user. The root user is the name given to a Linux user who can perform any operation on the machine without requiring permission from another user. The root user is also known as the Super User. This user's user ID is 0.

It's more powerful than Administrator in Windows, more akin to SYSTEM in Windows, and you can log into the system. The root user is in charge of creating new users and assigning various permissions on the machine. The command that must be run as a root user begins with Sudo.

Being a command, sudo is also a package that comes installed by default on the Linus systems. However, certain Linux distributions do not get sudo installed, and when you run the command on such systems, you receive the error message “sudo: command not found.”

Here is a solution that you can follow to fix the error:

  • Switch to the root user
  • Type in the following command to go to the root user mode

$ su -

  • Update the repositories using the following command

$ apt update

  • Run the following command on Debian-based distributions:

$ apt-get install sudo

  • The output will be something like this:

Reading package lists... Done
Building dependency tree     
Reading state information... Done
The following NEW packages will be installed:
 sudo
0 upgraded, 1 newly installed, 0 to remove and 0 not upgraded.
Need to get 0 B/1,059 kB of archives.
After this operation, 4,699 kB of additional disk space will be used.
Get:1 http://security.debian.org/ squeeze/updates/main sudo amd64 1.7.4p4-2.squeeze.3 [610 kB]
Fetched 610 kB in 4s (132 kB/s)
Selecting previously unselected package sudo.
(Reading database ... 135532 files and directories currently installed.)
Unpacking sudo (from .../sudo_1.7.4p4-2.squeeze.3_amd64.deb) ...
Processing triggers for man-db ...

  • Run the following command on RHEL/CentOS/Fedora:

$ yum install sudo

  • Give all the sudo permissions using the following command

$ user od -AG <username>

  • Open the 'sudoers' file to check the permissions

$ nano /etc/sudoers

  • Check if the sudo has all the permissions associated.

# Full access for members of the sudo group
%sudo ALL=(ALL:ALL) ALL
# User privilege specification
root ALL=(ALL:ALL) ALL

  • You should now be able to run all the commands using sudo.

For security purposes, the Linux systems provide permissions only to the root user and the users allowed by the root user to perform administrative tasks. We hope the above solution will help you fix the error “sudo: command not found” on most Linux distributions.

Good Luck!

People also read: 

Susith Nonis

I'm fascinated by the IT world and how the 1's and 0's work. While I venture into the world of Technology, I try to share what I know in the simplest way with you. Not a fan of coffee, a travel addict, and a self-accredited 'master chef'.