[SOLVED] Git clone command not found Kali Linux

git clone command not found – Kali Linux

The problem – git clone command not found

I could see, that the latest version of Kali Linux VirtualBox image came with the git command installed. However, if you see a problem with the git – such as the git command not being found – or Package git is not available, but is referred to by another package as shown below:

$ git clone https://gitlab.com/kalilinux/nethunter/build-scripts/kali-nethunter-project.git
Command 'git' not found, but can be installed with:
sudo apt install git
Do you want to install it? (N/y)

And, when you give Yes to that, it fails:

Do you want to install it? (N/y)y
sudo apt install git
Reading package lists... Done
Building dependency tree... Done
Reading state information... Done
Package git is not available, but is referred to by another package.
This may mean that the package is missing, has been obsoleted, or
is only available from another source

E: Package 'git' has no installation candidate

I followed the below steps to solve both these errors and get the git command working.

Step #1 Cleanup the APT cache

Cleanup your apt cache:

sudo rm -vrf /var/lib/apt/lists/*

Step #2 Update apt

Run apt update using apt-get update command:

sudo apt-get update

Step #3 Finally, install the git SCM tool:

 sudo apt install git

This should go well if you have sudo permission and have an internet connection. Finally, test the git command by cloning the nethunter repository again.

Step #4 Testing git clone command

git clone https://gitlab.com/kalilinux/nethunter/build-scripts/kali-nethunter-project.git
git clone command Kali Linux

It works. Yaay!

We have used GitLab URL to test clone the repository, commands and steps followed here are similar, and the solution will fix if you face a problem with GitHub URL as well.

If you have more questions, please let us know.

Related: How to run Kali Linux VirtualBox VM on Windows


Error – Could not open lock file /var/lib/dpkg/lock-frontend – open (13: Permission denied)

This happens if you are trying to run the apt install command without the sudo prefix, run the command with sudo, such as sudo apt install git

Error – Package git is not available, but is referred to by another package

To fix this, please follow all steps described earlier, Steps #1, #2 and #3.

Kali Linux command asking for the password, which password I should give?

The default username & password for kali is kali

If you have changed it, provide the current password for the user kali.

Problem:- Kali Docker container ( kali-rolling ), git command not found or git clone command not found

kali-rolling container throws the error: git: command not found.

└─# git clone
bash: git: command not found

The Docker image, kali-rolling is a basic OS image, and there are no tools by default. You can install git by running commands, as shown below:

rm -vrf /var/lib/apt/lists/*
apt-get update
apt install git

Do not use the sudo prefix here, because the command sudo is not available in the container.

└─# sudo apt install git             
bash: sudo: command not found

You can find more information on this on the official page: https://hub.docker.com/r/kalilinux/kali-rolling