The error message -bash: sudo: command not found
means that the sudo
command is not installed or not in your shell’s PATH. sudo
is a command that allows users to run commands with elevated privileges (as the superuser).
Here are some steps to resolve the error:
- Check if
sudo
is installed:
which sudo
If the output is sudo not found
, then sudo
is not installed on your system.
- Install
sudo
:
$ su -
# yum install sudo
or
$ su -
# apt-get install sudo
This will install the sudo
package on your system.
- Add the
sudo
command to your shell’s PATH:
echo 'export PATH=$PATH:/usr/local/bin' >> ~/.bashrc
source ~/.bashrc
This will add the /usr/local/bin
directory to your shell’s PATH, which is where the sudo
command is located on most systems.
- Verify that the
sudo
command is working:
sudo echo 'Hello, world!'
If the sudo
command is working, the output should be Hello, world!
.
If you continue to receive the error message after following these steps, you may need to consult the documentation for your specific Linux distribution for additional guidance.