H2S Forum

Bash sudo command not found centos 7/6 or Redhat

If you are trying to run some command with sudo and getting an error

bash: sudo: command not found

su and sudo are two different things, the above error means the system doesn’t have the sudo installation. Thus, here is the solution:

Login as a root user

First you should have root rights of your system.

su -

The above command will ask for your root user password.

Install Sudo on CentOS Linux

Now simply run the command:

yum install sudo 

Output of above command:

[root@5266fecf435b ~]# yum install sudo
Loaded plugins: fastestmirror, ovl
Loading mirror speeds from cached hostfile
 * base: centos.excellmedia.net
 * extras: centos.excellmedia.net
 * updates: centos.excellmedia.net
Resolving Dependencies
--> Running transaction check
---> Package sudo.x86_64 0:1.8.23-3.el7 will be installed
--> Finished Dependency Resolution

Dependencies Resolved

 Package                  Arch                       Version                             Repository                Size
 sudo                     x86_64                     1.8.23-3.el7                        base                     841 k

Transaction Summary
Install  1 Package

Total download size: 841 k
Installed size: 3.0 M
Is this ok [y/d/N]: y
Downloading packages:
sudo-1.8.23-3.el7.x86_64.rpm                                                                     | 841 kB  00:00:06
Running transaction check
Running transaction test
Transaction test succeeded
Running transaction
  Installing : sudo-1.8.23-3.el7.x86_64                                                                             1/1
  Verifying  : sudo-1.8.23-3.el7.x86_64                                                                             1/1

  sudo.x86_64 0:1.8.23-3.el7


Now you will be able to use commands with sudo.
We can even emulate our current to use sudo rights using a command:

sudo -i