This is one of the most common problems new Linux users face after a fresh installation.

Here’s how you’re free to solve this issue and start using the sudo command again.

For this tutorial, I’ll be demonstrating everything on Debian 12.

Example of a terminal with the error ‘sudo command not found’ and a notebook with the Linux mascot on the screen

Lucas Gouveia/How-To Geek |monticello/Vegorus/Shutterstock

What Is the sudo Command?

With sudo, authorized users can perform administrative tasks without needing to sign on as the root user.

The way to use sudo is to begin another command with the word “sudo”.

An example of the error sudo command not found on Debian Linux being displayed on the terminal

This allows you to launch the command with elevated privileges.

So the sudo command lets you have the required permissions of a different user and run a sensitive command.

you’re free to learn more about the sudo command from itsmanual page.

An example of checking the version of sudo installed on Debian using the sudo -V command

Why Are You Getting This Error?

There are usually two possible reasons for the “sudo: command not found” error on Linux.

Some Linux distributions may not have the sudo package installed by default.

An example of becoming root user on Debian Linux using the su - command

This is true for Arch and Gentoo Linux.

On Debian, if you set a root password during installation, then you’ll face the same problem.

The second reason is that sudo is installed, but its directory is not included in the PATH variable.

The Linux terminal showing the process of installing the sudo command as a root use

PATH is an environment variable the Linux system uses to locate a command without specifying its full path.

Install sudo on Linux

To roll out the sudo package, you should probably becomerootfirst.

As a root user, you might install any software package, including sudo.

The Linux terminal displaying the command to add a user to the sudoer group on Debian

This is because you want to give that user superuser privileges.

Then your non-root user can use the sudo command to gain elevated privileges.

For example, let’s give a shot to update the packages on the system.

The Linux terminal demonstrating the process of switching between users on Debian using commands

To do that, use:

It works as expected.

Let’s first determine the location of the sudo command.

As you’ve got the option to see, it’s in the “/usr/bin/” directory.

An example of updating the packages on Debian Linux using the sudo apt update command

Now let’s verify if the directory is in the PATH variable or not.

After you end the terminal session, things will go back to what they were.

To permanently add the directory, launch the “/etc/profile” file in a text editor.

An example of using the which command on Linux to display the location of a certain command

Save the file using Ctrl+O and then exit from the editor using Ctrl+X.

Now venture to use the sudo command to see if it’s working.

That should solve your problem and let you use the sudo command without any errors.

The Linux terminal displaying the PATH variable content on Debian

Remember that, only the users added to the sudo group will be able to use it.