List of content you will read in this article:
In Linux and UNIX-like systems, the Sudo command is used to execute a specific command with root privileges. The user who runs this command has complete access to the system and can modify or add anything to it. Although the command is installed by default in all Linux operating systems, you may receive a "Sudo command not found" error when using it in rare cases. Fortunately, we have a simple solution for this problem, which we will discuss in this article.
What is the Sudo command?
Sudo (superuser do) is a command-line utility that is usually built-in for UNIX and Linux-based Operating Systems and grants the users the permissions to execute different commands at the most potent level of the system, which is the root level. Sudo also keeps a log of all commands and arguments.
What is a root user?
The root user is the name given to a Linux user who can perform any operation on the machine without requiring permission from another user. The root user is also known as the SuperUser. This user's user ID is 0. It's more powerful than Administrator in Windows, more akin to SYSTEM in Windows, and you can log into the system. The root user is in charge of creating new users and assigning various permissions on the machine. The command that must be run as a root user begins with Sudo.
Fixing Sudo command not found errors
Although it is uncommon to not receive a Sudo command after installing a Linux distribution, you can try the solution listed below if you encounter this problem.
- Switch to root user
- Type in the following command to go to the root user mode
$ su -
- Update the repositories using the following command
$ apt update
- Run the following command on Debian based distributions:
$ apt-get install sudo
The output will be something like this:
Reading package lists... Done
Building dependency tree
Reading state information... Done
The following NEW packages will be installed:
0 upgraded, 1 newly installed, 0 to remove and 0 not upgraded.
Need to get 0 B/1,059 kB of archives.
After this operation, 4,699 kB of additional disk space will be used.
Get:1 http://security.debian.org/ squeeze/updates/main sudo amd64 1.7.4p4-2.squeeze.3 [610 kB]
Fetched 610 kB in 4s (132 kB/s)
Selecting previously unselected package sudo.
(Reading database ... 135532 files and directories currently installed.)
Unpacking sudo (from .../sudo_1.7.4p4-2.squeeze.3_amd64.deb) ...
Processing triggers for man-db ...
- Run the following command on RHEL/CentOS/Fedora:
$ yum install sudo
- Give all the sudo permissions using the following command
$ user od -AG <username>
- Open the 'sudoers' file to check the permissions
$ nano /etc/sudoers
- Check if the sudo has all the permissions associated.
# Full access for members of the sudo group
%sudo ALL=(ALL:ALL) ALL
# User privilege specification
root ALL=(ALL:ALL) ALL
You should now be able to run all the commands using sudo.
This article went through a solution for the "Sudo command not found" error. This solution will work on most Linux distributions as we have demonstrated the steps keeping in mind multiple Linux distributions.
People also read: