“-bash: sudo: command not found” Error and Solution For Linux, Debian, CentOS – POFTUT

“-bash: sudo: command not found” Error and Solution For Linux, Debian, CentOS


sudo  command is used to execute command as another user. This is generally used to run command as root. In some cases we can get an error like -bash:sudo:command not found which means sudo is not installed. In this tutorial we will look different ways and distributions to solve this problem.

Install Sudo For Debian, Ubuntu, Mint, Kali

We can install sudo for Debian, Ubuntu, Mint and Kali related distributions for deb or apt with the following command. But before we should be root user because package installation requires root privileges.

$ su
$ apt install sudo

Install Sudo For CentOS, Fedora, RHEL

We can install sudo for CentOS, Fedora and RHEL related distributions for rpm or yum with the following command. But before we should be root user because package installation requires root privileges.

$ su
$ yum install sudo

Add User Sudoers Configuration File

sudo command provides fast way to change root user. But this is done with a configuration file locate /etc/sudoers . sudoers file contains users and their ability to run sudo command. Most of the distributions automatically adds user to this file but in some cases this may fail. We can add following line to make user able to run sudo . In this example we will use user name ismail

ismail        ALL=(ALL)  ALL

Become Another User

While using sudo if we need to change user other than root we should provide the user name after the sudo command . In this example we will change to the user ali

$ sudo ali

LEARN MORE  What is chmod 777?

Leave a Comment