Have you just installed Kali Linux in VirtualBox and tried running the commands apt-get install or apt-get update and it’s not working? Here is the solution or fix for it, very easy!
This problem might likely be caused by a lack of internet connection in your Kali Linux virtual machine. So let’s, first of all, be sure it’s not your internet connection.
Open a terminal window and type “ping google.com”.
If your terminal output is similar to the screenshot above then your internet connection is ok, continue with this post otherwise fix it using the instructions here.
Secondly, it might be that your time and date is out of sync with the host OS if you’re running a Virtual Machine. Probably because you’re restoring the VM from a snapshot, in which case you want to use the command below to fix that.
sudo service ntp restart
If this also fails then continue reading for the ultimate solution 🙂
FIX: apt-get Not Working in Kali Linux 2020.3 and Beyond
Watch this video to fix it or continue with the written steps, either way you will fix this very easily.
It’s a minor problem that occurs when your Kali Linux repository ‘sources.list‘ file is empty for some weird reason.
Your terminal will throw up an error similar to the one in the screenshot below when you try to either update or install any program. Here is how to fix that easily.
Open a terminal window and follow the below instructions:
Step 1: Type the code below in a terminal
sudo nano /etc/apt/sources.list
Step 2: Navigate with the down arrow key on your keyboard to the bottom of the page and type in the official Kali Linux repository source.list address.
deb http://http.kali.org/kali kali-rolling main non-free contrib
Step 3: Press “Ctrl + X” key on your keyboard to exit. Press “Y” key for yes, and “Enter” key to confirm. (Note: the Ctrl key you should use is the one on the left side of your keyboard)
Step 4: Now test that you can now update and install programs.
Alright, that’s all for fixing apt-get not working in Kali Linux.
If you face further issues relating to GPG Keys when you try to install programs, follow the instructions in this post to renew/update your GPG keys.
As usual, if you have any queries, ask them in the comments and I’ll get back to you ASAP. Also, do drop a comment if this post worked for you.