Sudo is a program that let users run programs with the security privileges of another user. To run administrative applications in Linux, users can take advantage of sudo. In this article, you will learn How to fix sudo command not found, to be able to continue using its benefits since users usually face the error ‘’command not found’’ even if they have the command installed.
After buying Linux VPS, you will start installing programs, running a Linux command, or setting up a new Linux desktop. All of these actions must be done using Sudo. So, it is inevitable to be mastered to fix sudo command not found error.
An Intro to Linux Sudo Command
The sudo command, which stands for “superuser do,” is a command-line utility that enables a user of the sudo group to issue commands in the same way as the root user. As long as they utilize sudo and password-authenticate, it basically grants them root privileges. Only superusers are permitted to run the sudo commands, and it is typically used as a prefix for numerous other Linux commands. This command is comparable to Windows’ “Run as Administrator” option. A log of all commands and arguments is also kept by sudo.
There are several user accounts on the Linux system. To prevent user accounts damage the Linux system while performing administrative tasks and not being able to access sensitive areas of the filesystem and run certain files, they come with limited privileges. The root user is not included with mentioned restrictions and is able to do any actions on the Linux system and also access all certain areas and run any sensitive commands. Obviously, the root account must be disabled. In this situation, the Sudo is used instead.
Using sudo instead of the root user is advised while operating a Linux system. This reduces the chance that potentially dangerous commands in linux may cause the system to crash. Most Linux distributions include the sudo package by default, so using it shouldn’t be a problem.
The ”sudo not found” error is not a big deal and using this guide you can easily learn how to fix the errors like -bash: sudo command not found or fix sudo command not found.
Why ”sudo command not found” occur?
In Linux and UNIX-like systems, the Sudo command executes a specific command with root privileges. This does not necessarily hold true for all Linux distributions, though. There are some situations where sudo may get removed or not pre-installed on the system such as Debian 10 and later, and it causes receiving the error message ”sudo: command not found.”
When working on a Linux system, especially on a newly installed Linux system, it is not that unusual to get the Bash sudo command not found error. If you faced this error while installing and setting up your Linux server, do not get disappointed and just follow the simple steps of this guide to learn the best way you can fix sudo command not found and get rid of receiving this frustrating error and proceeding further with the setup process.
As you guess, the solution to solve the sudo: command not found error is to install it on your Linux server. In the following of this tutorial, you will learn how to do this easily.
Easiest Technique to Fix Sudo Command Not Found Error
Let’s go through this tutorial and find the simple solution to fix sudo command not found, once forever. You must log out of your user account and log in as root because your user cannot take on the rights of the root user unless sudo is already installed. You can install the sudo package as the root user using the permissions that this account has.
To log into your system, run the command below as the root user:
$ sudo su -
You can also switch to the root user. Now, you can update the package lists and install the sudo package. So, simply run:
# apt update -y # apt install sudo -y
To install sudo on CentOS Stream, Fedora, Rocky Linux, or Alma Linux, use the following command to switch to the root user and then, install sudo:
# su - # yum install sudo
To install sudo on Arch Linux, type:
# pacman -Sy sudo
On Debian-based systems, enter:
apt install sudo
To give all the sudo permissions, run:
$ user od -AG <username>
Then, you can check the permissions by opening the ‘sudoers’ file:
$ nano /etc/sudoers
Now, you should be able to use sudo to execute all the commands.
Add User to Sudo Group in Linux [CLI & GUI Methods]
Once you solve the sudo: command not found error, you can add users to the sudo group. Find and use the related command of your running distribution. If you prefer to use the graphical interface to add user to sudo, skip the first method to the second one.
1. Using Command-Line
Launch the terminal and run the following command to add a Superuser on Ubuntu and Debian:
sudo adduser username
Run the following command to add your user to the sudo group on Debian:
usermod -aG sudo your_username
Then, you can confirm whether the user has been added to the group by issuing the following command:
# groups your_username
Replace the name of the user you need to check that has been added to the group with your-username in the above command.
To add the user to the wheel group on Arch-based systems, type:
usermod -aG wheel your_username
And use the command below to add your users to the sudo group on Fedora and other RHEL-based distros:
usermod -aG wheel your_username
By the way, you can use a single command instead of multiple commands to create a new superuser:
sudo adduser username sudo
The verification procedure is unchanged from before.
To test if the error has gone, log back in as your regular user. If all have passed successfully, you should not view the ‘’sudo: command not found’’ error anymore, and fixing sudo: command not found must have been finished at this point.
2. Using Graphical Interface
To use the GUI method to add the user to the sudo, you must first create a new user through the command line and then, follow the below steps to proceed.
Step 1. To view a list of users and find the newly created user/users, go to the Application menu and click on the Users option.
Step 2. Here you can switch to another user account if you click on the Unlock option and on the root password.
As soon as you choose it, an option to make the newly created user account an administrator account will appear. To add the account as a sudo account, toggle the button next to the Administrator label.
There, you added a sudo user using the graphical interface.
What to Do After Fixing sudo: command not found in Linux?
According to your running distribution, you can choose the related commands explained in this guide to fix sudo command not found. When everything finished successfully, you can run any command and access any place without having to log in as root because you successfully installed sudo and added your user to the sudo group. Although sudo significantly increases the security of your Linux machine, you should exercise caution when using this power because elevated privileges can be risky, especially in production environments.
On Linus systems, sudo is a package that is pre-installed. However, sudo is not installed on some Linux editions, and when you run the command on one of these systems, you get the error "sudo: command not found."
No. Su and sudo both increase the current user's privileges. The primary distinction between the two commands is that su calls for the target account's password, whereas sudo calls for the current user's password. Therefore, using sudo is significantly safer because it avoids sending sensitive information.
When sudo run commands with a fresh environment instead of inheriting modified environment variables, the ‘’command not found’’ error will be displayed.
In this article, you learned about sudo: command not found error, the reason for occurring, and the way you can fix it. Obviously, due to security reasons, in Linux systems only the root user and users who have been granted administrative task rights by the root user are given permissions. As you reviewed, this error is not that complicated contrary to its appearance. You just need to go into the root user mode and install the sudo tool using the existing commands in this article. We tried to offer the best and simplest solution to help you fix sudo command not found and continue performing commands on your Linux system.
If you follow the above steps properly then you can smoothly fix the error, but do not hesitate to contact us if you encounter any problems. Our technical support team will try their best to solve your problems.