Skip to content

How to fix ‘Sudo command not found’ error on Linux?

  • by
  • 3 min read

Anyone who has been using Linux for some time will know the importance of the sudo command. It lets you run commands from the terminal with admin rights and is extremely important if you’re making changes to your Linux machine.

However, you might sometimes run into errors saying, “sudo command not found.” While this happens rarely, it can be a big problem. In this article, we’re going over how you can fix this error.

Also read: How to change file permissions recursively using Chmod in Linux?


How to fix sudo command not found error on GNU/Linux?

If you’re using a Linux distro, it’s unlikely that you’ll be getting this error. However, if you do, it can be installed using the following commands for whatever reason.

For Debian based systems

apt-get install sudo
How to fix 'Sudo command not found' error on Linux?

For Fedora, Red Hat or other RMP systems

yum install sudo

Once the command has run successfully and installed sudo, you’re going to have to get permissions to use the command. Just follow these steps.

Step 1: Type visudo in the terminal and hit enter.

How to fix 'Sudo command not found' error on Linux?

Step 2: Add this line at the end of the file. Make sure to add your username instead of [username] below.

[username] ALL=(ALL) ALL
How to fix 'Sudo command not found' error on Linux?

Save and exit the file, and the sudo command should start working.

Also read: How to sort Is command by date?


How to fix sudo command not found error on FreeBSD and other Unix distros?

If you’re using a FreeBSD or any other Unix-based distro, run the following command to install sudo.

pkg_add -rv

Once the command has run successfully, we will give our user permissions to run the command. Just follow these steps. 

Step 1: Type visudo in the terminal and hit enter.

How to fix 'Sudo command not found' error on Linux?

Step 2: Add this line at the end of the file. Make sure to add your username instead of [username] below.

[username] ALL=(ALL) ALL
How to fix 'Sudo command not found' error on Linux?

Save and exit the file, and the sudo command should start working.

Once again, it’s somewhat unconventional for a Linux or Unix based distro to not have sudo installed by default. If you don’t have sudo, chances are you’re missing several other essential packages as well. Unless you’re willing to install all of them manually, you should reinstall your OS once more.

Also read: How to access command line history on Linux?

Yadullah Abidi

Yadullah Abidi

Yadullah is a Computer Science graduate who writes/edits/shoots/codes all things cybersecurity, gaming, and tech hardware. When he's not, he streams himself racing virtual cars. He's been writing and reporting on tech and cybersecurity with websites like Candid.Technology and MakeUseOf since 2018. You can contact him here: yadullahabidi@pm.me.

>