Red Hat command returns, “-bash: sudo: command not found” when running “sudo git”
I’m following a GoDaddy help tutorial in order to install “Let’s Encrypt” certificate for my website.
So I connected to my server using SSH via PuTTy and when typing the first command:
sudo git clone I get the error:
-bash: sudo: command not foundAfter typing cat /proc/version I found that I have a Red Hat dist, so what should I do?
1 Answer
That GoDaddy! tutorial seems a bit odd in my humble opinion. There is utterly no reason to use sudo with git since all Git is really is a version control system. So I believe your core problem is Git is not installed on your system to begin with. To solve that just connect to your server via SSH and run this command:
sudo yum install git-allThen once Git is installed try running this command to clone the “Let’s Encrypt” tutorial; same command as their first command but without sudo:
git clone The follow the rest of the instructions on that tutorial and I’m pretty sure you will be fine.
UPDATE: Also, looking at those GoDaddy! Git installation instructions you provided—which explains an incredibly over-complex way to install Git— it’s easy to see how you could have overwritten your default ~/.bash_profile. Honestly the GoDaddy! instructions seem like they are designed to create more problems than they solve. So it’s best to undo that mess.
And if you overwrote your default ~/.bash_profile—or set it to something odd/complex—it’s easy to see how it could screw up your setup to the point it’s impossible for the system to be able to find a basic command like sudo.
So I would recommend moving ~/.bash_profile to a backup file so you still have it but it’s not active like this:
mv ~/.bash_profile ~/.bash_profile.bakAfter that is done, log back in and type in the following command:
which sudoThe output of that should be something like this:
/usr/bin/sudoWhich now means your PATH settings are fine and back to normal.
Now, to get rid of that odd Git version GoDaddy! instructed you to install by doing this. First, just get back to your home directory like this:
cd ~/Then run this command:
rm -rf ~/opt/usr/bin/git --versionThen logout and log back in and then things should be fine. With that cleaned up, use Yum to install Git and you should be good to go!
2