Red Hat command returns, “-bash: sudo: command not found” when running “sudo git”

-1

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 https://github.com/letsencrypt/letsencrypt

I get the error:

-bash: sudo: command not found

After typing cat /proc/version I found that I have a Red Hat dist, so what should I do?

Hamza

Posted 2016-06-25T00:47:09.427

Reputation: 1

1

sudo isn't automatically installed or configured for many distros by default. if you set a root password during install, just use su and authenticate as the root user to run commands as root, or install and configure sudo. http://unix.stackexchange.com/questions/55818/how-to-use-sudo-in-fedora

– Frank Thomas – 2016-06-25T04:08:25.040

Answers

2

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-all

Then 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 https://github.com/letsencrypt/letsencrypt

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

After that is done, log back in and type in the following command:

which sudo

The output of that should be something like this:

/usr/bin/sudo

Which 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 --version

Then 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!

JakeGould

Posted 2016-06-25T00:47:09.427

Reputation: 38 217

the problem is sudo: command not found ... so how can you give an anwser proposing to use sudo ??? – Gabriel Matusevich – 2017-07-26T23:21:22.983

@GabrielMatusevich Please read my answer again; using sudo is not the core of the answer. My answer proposes ditching the ~/.bash_profile and then logging out and logging in again to see if sudo can be found again. At no point do I recommend using sudo; it is just a diagnostic based on the content of the original poster’s question. – JakeGould – 2017-07-27T02:13:19.777