This write-up is associated with the solution with which we can resolve this error. We will discuss both errors separately which are related to the sudo package, when we face them and how we can resolve these issues.
How to FIX: Debian sudo command not found
By default in Debian, the sudo command is installed but sometimes it happens that we use the sudo command and it generates the following error.
We simply enter the root user mode as:
So it means that the sudo package is not installed by default so to resolve this issue we simply go to the user mode and install the package. First, we will go to the root user mode.
Update the repository first.
Install the sudo package.
Exit the root mode.
To verify the installation of the error we will again enter the root by using sudo command.
The issue which has been discussed at the start is now resolved.
How to add user to sudoers file to resolve the error
We simply run the command of the list of disks on Debian.
We have the output, “zhammad is not in the sudoers file . This incident will be reported.”, this is an error which means we cannot use the sudo command. Sudo command is an administrative command which is used with those commands which need administrative permissions. Now it means the user “zhammad” does not have the administrative rights so to access those permissions we have to install the “sudo command” manually and give the administrative privileges to this user.
We will switch the user to administrative user which is “hammad” in our case. So by using the “su command” we switch to hammad from zhammad.
Now as we switch the user to hammad, we will go to the root mode.
Update the repository of Debian by using the update command.
As we can see in the output, the repository is updated and all the packages are up to date so no need to upgrade the repository. Now we add the new user in the list of sudoers file by using the command.
The user has been added to the list of sudoers and for the verification of this we used the command of “id”.
In the above output, we see the zhammad user is also added to the list of sudo. After verifying this we will exit the root mode by typing “exit”.
For switching back to the zhammad from hammad.
Again run the command of fdisk and confirm that the issue has been solved.
The command runs successfully and displays the list of disks. So our issue has been resolved.
Conclusion
Sudo is used for the commands which are making the changes in the root folder and administrative things. For a secure purpose, these permissions are only given either to the root user or the user which are allowed by the root user. We have discussed the solution of the issue in this write-up which is to resolve it by installing the sudo manually (if it is not installed so can be installed by this command else it is installed in Debian by default) and adding the user to the list of sudoers by switching to the administrative user account. I tried to assist you with the solution of “sudo command not found” in this write-up and hope this will help you in resolving the issue.