-bash: sudo: command not found Error and Solution

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:

  1. Check if sudo is installed:
$ which sudo

If the output is sudo not found, then sudo is not installed on your system.

  1. Install sudo:
$ su -
# yum install sudo

or

$ su -
# apt-get install sudo

This will install the sudo package on your system.

  1. 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.

  1. 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.

(topvillasrealty.com)

Leave a Comment