Recently, I deployed a Debian 10 managed VPS and noticed that I could not execute privileges tasks by invoking the sudo command. Instead, I got the error ‘sudo command not found in Debian 10′. Turns out that the sudo command-line tool is not present by default. However, I managed to fix the problem in a few simple steps. In this guide, we will show you how to resolve the ‘sudo command not found in Debian 10′.
How To Fix Sudo Command Not Found
To elaborate on the error I encountered, here’s a screenshot from the putty client console. As you can see, I couldn’t even update the package lists of my Debian system. As you would imagine, this can be a very frustrating experience.
Thankfully, this can be resolved in a few simple steps. The only thing that you need to do is to install the sudo command. Let’s see how.
Step 1: Install the ‘sudo’ command
Installing sudo is quite a piece of cake. To achieve this, log in or switch to root user and use the APT package manager to update the system package list.
# apt update
Then install sudo as shown.
# apt get install sudo
Alternatively, you can concatenate these two commands:
# apt update && apt install sudo
When prompted to continue. hit ‘Y‘ to proceed.
And that’s about it. If you have a new or existing user, you need to add that user to the sudo group. In effect, this grants sudo privileges to the user, and this allows them to use the sudo command to perform administrative privileges.
Step 1: Add a regular user to the sudo group
To add the user to sudo group, use the usermod command as shown:
# usermod -aG sudo username
For example, to grant a user ‘james’ administrative privileges, run:
# usermod -aG sudo james
To confirm that the user has been added to the sudo group, use the id command as shown.
$ id james
From the output, you can clearly see that the user ‘james’ belongs to two groups: ‘james‘ and ‘sudo‘. Going forward, you can switch to the user and execute elevated tasks using the sudo command.
$ su james $ sudo apt update
This brings a close to this topic. We do hope that you are now able to fix the ‘sudo command not found‘ issue. Thank you for taking your time and as always, your feedback is much appreciated.