The problem is that the git clone command is not found
I could see that the latest Kali Linux VirtualBox image version 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 steps below to solve 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 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
It works. Yaay!
We have used the GitLab URL to test clone the repository, The commands and steps followed here are similar, and the solution will be fixed if you face a problem with the GitHub URL.
If you have more questions, please let us know.
Related: How to run Kali Linux VirtualBox VM on Windows
FAQs:
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 the steps described earlier: Steps #1, #2 and #3.
The Kali Linux command asks for the password. Which password should I 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.
┌──(root㉿0089169ffd11)-[/]
└─# git clone
bash: git: command not found
The Docker image, kali-rolling is a bare 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 unavailable in the container.
┌──(root㉿0089169ffd11)-[/]
└─# 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
What is Kali Linux used for?
Kali Linux is a specialized distribution designed for cybersecurity professionals, ethical hackers, penetration testers, and individuals interested in information security. It provides a comprehensive set of tools and resources for various security-related tasks, including penetration testing, vulnerability assessment, digital forensics, and network analysis.