Summary: sudo command isn’t included in Debian by default. That’s why you get the error message saying “-bash: sudo: command not found”. In this article I will show you how to fix sudo command not found in Debian.

“sudo” is a Linux command which grunt you the permission to execute programs with the security privileges of another user. By default, it will give you the “superuser/root” privileges to execute your programs.

After a fresh install of Debian, if you try to install or update your system using command line together with sudo command it will prompt you with an error saying that “-bash: sudo: command not found”.

-bash: sudo: command not found error in Debian/Ubuntu

Here is the step by step guide on how to fix sudo command not found in debian.

  • Switch to the root account using the “su” command. When it prompts you to enter a password, enter the root password you specified during the installation.
switching to root account in Debian
  • Update your repositories using the below command.
apt update
Updating Debian using apt command
  • After finishing the update, install the sudo utility using the below command.
apt install sudo
Installing sudo command in Debian

Also Read: How Does Hardware And Software Work Together

Now we need to add existing user in our machine to sudoers group. If you don’t add user to this group, every time when you run the sudo command it will give an error.

<Username> is not in the sudoers file error
  • Run the command “visudo” while being root.
visudo
  • Add the user name together with same privileges as root under user privilege specification section.
adding users to sudoers file
  • Now switch to the regular user account that you’ve added in the sudoers file and try to run “sudo” command to install a package or update the system.
  • That’s it. You should now be able to update and install new packages without getting the “-bash: sudo: command not found” error.

Thank you for reading. I hope you were able to fix the “sudo command not found” error with the help of this article.

Write A Comment