Today I have installed Kali Linux on my Desktop. When the installation part is over, the first and foremost part is to update the system repositories to get the latest updates of available applications.
So, I’ve passed the update command “sudo apt update && apt upgrade -y”, and I’ve noticed that the update is taking longer than expected. Of course, after that, I checked the internet speed, and the speed was good enough to handle 4k video.
This issue was not new to me, so I have replaced the official mirror with a new mirror link without wasting any moment, and the problem was resolved.
In this guidepost, we will show you how to fix slow apt updates. Before that, let’s understand why the update is slowing down.
Slow fetching update from official repositories
Whenever you update the Kali official repository, all the required files are fetched from the default repository http://http.kali.org.
A default server may get swamped up with a large number of ongoing connections, resulting in a slow update, and even you may get a high-speed connection once the server is free.
We’ve got a list of available repositories to solve this problem, and the main thing servers are located worldwide.
Now we will see how to replace the default repositories link with the available mirror links.
View and backup /etc/apt/source.list file
A default sources.list file stored at /etc/apt/sources.list, to view content, open a terminal and pass the following command:
$ sudo cat /etc/apt/sources.list
View Default sources. list
$ sudo nano /etc/apt/sources.list
Before making changes to the source file, you should make a backup copy to avoid the unexpected. Let me show you how to take a backup of /etc/apt/sources.list file.
Pass the following command into your terminal window:
$ sudo cp /etc/apt/sources.list /etc/apt/sources.listbak
To confirm, type the below command, and once the file is a present, move to the next part:
$ ls /etc/apt/*.listbak
Change mirror list from /etc/apt/source.list
After that, your task is to find the best available mirror link. For that, refer to Check Mirror Link.
Open the above link and copy any mirror link from the list into your clipboard. Personally, I have selected the latest mirror link, which is the best among all the “https://mirrors.ocf.berkeley.edu/kali/“, and I suggest you to use the same mirror link.
Let’s get back to the terminal and open the same file with sudo privileges for modifications:
# nano /etc/apt/sources.list
Default sources.list
I think you will also use the same mirror link that I am using, so you can directly copy and paste the following code into /etc/apt/sources.list
:
deb https://mirrors.ocf.berkeley.edu/kali/ kali-rolling main contrib non->
# For source package access, uncomment the following line
# deb-src https://mirrors.ocf.berkeley.edu/kali/ kali-rolling main contrib>
After Modification /etc/apt/sources.list
Now save this file and run the update process.
$ sudo apt clean
$ sudo apt update && apt upgrade -y
You will see a speed improvement, and if it is same, you will need to select another mirror link.
Read this :- The complete guide for NMAP Command
Get Mirror Link
To use a different mirror link, go to the same URL and select any link from it. For example, I will copy the last link, “https://mirrors.ocf.berkeley.edu/kali/“.
Note:- Copy the URL till /kali don’t include README.
After this, again open the /etc/apt/sources.list
using nano
or vim
and replace the default source with a mirror link.
Try again to update the official repository.
Wrap-up
Your problem will be solved with the mirror link that we have provided if you have made any unwanted changes in the source list, then you can restore the backup.
Let me know if you encounter any problems while making the changes.
A man with a tech effusive who has explored some of the amazing technology stuff and is exploring more. While moving towards, I had a chance to work on Android development, Linux, AWS, and DevOps with several open-source tools.