Kali Linux updating troubleshooting

A full system update is performed as follows:

sudo apt update && sudo apt -y full-upgrade

The update process requires:

  • correct entry in repository list (application sources)
  • Internet connection

Application sources (repositories) are written in the /etc/apt/sources.list file

To open a file, use the command

gedit /etc/apt/sources.list

Lines that begin with the # character are comments, do not pay attention to them.

It is important that there is a line:

deb https://http.kali.org/kali kali-rolling main non-free contrib

And this line should be the only uncommented.

The string can be:

deb http://http.kali.org/kali kali-rolling main non-free contrib

It is identical, but HTTP is specified instead of HTTPS. The main thing is to have one of these options, and there are no other uncommented lines.

For more information on updating Kali Linux, any other commands and questions related to updating, see the help article “How to update Kali Linux”.

Error ‘E: Failed to fetch … Cannot initiate the connection’

Part of the output when information update failed because the connection was broken:

Get:4 https://hlzmel.fsmg.org.nz/kali kali-rolling/main amd64 python3-distutils all 3.7.2-3 [142 kB]
Get:5 https://hlzmel.fsmg.org.nz/kali kali-rolling/main amd64 libpython3.7 amd64 3.7.2-2 [1,494 kB]
Get:6 https://hlzmel.fsmg.org.nz/kali kali-rolling/main amd64 libpython3.7-stdlib amd64 3.7.2-2 [1,731 kB]
E: Failed to fetch https://http.kali.org/kali/pool/main/x/xserver-xorg-video-ati/xserver-xorg-video-ati_18.1.99+git20190207-1_amd64.deb Cannot initiate the connection to http.kali.org:443 (192.99.200.113). - connect (101: Network is unreachable) [IP: 192.99.200.113 443]
E: Failed to fetch https://http.kali.org/kali/pool/main/x/xserver-xorg-video-nouveau/xserver-xorg-video-nouveau_1.0.16-1_amd64.deb Cannot initiate the connection to http.kali.org:443 (192.99.200.113). - connect (101: Network is unreachable) [IP: 192.99.200.113 443]
E: Failed to fetch https://http.kali.org/kali/pool/main/x/xterm/xterm_344-1_amd64.deb Cannot initiate the connection to http.kali.org:443 (192.99.200.113). - connect (101: Network is unreachable) [IP: 192.99.200.113 443]
E: Failed to fetch https://http.kali.org/kali/pool/main/z/zeitgeist/zeitgeist-core_1.0.1-1_amd64.deb Cannot initiate the connection to http.kali.org:443 (192.99.200.113). - connect (101: Network is unreachable) [IP: 192.99.200.113 443]
E: Unable to fetch some archives, maybe run apt-get update or try with --fix-missing?

Or it can be:

Get:1102 https://hlzmel.fsmg.org.nz/kali kali-rolling/main amd64 zeitgeist-core amd64 1.0.1-1 [141 kB]                                                                                                            
Fetched 2,571 MB in 54min 56s (780 kB/s)                                                                                                                                                                          
E: Failed to fetch https://hlzmel.fsmg.org.nz/kali/pool/non-free/n/nvidia-cuda-toolkit/libnvgraph9.2_9.2.148-5_amd64.deb  Connection timed out [IP: 163.7.134.121 443]
E: Failed to fetch https://hlzmel.fsmg.org.nz/kali/pool/non-free/f/firmware-nonfree/firmware-iwlwifi_20190114-1_all.deb  Connection failed [IP: 163.7.134.121 443]
E: Unable to fetch some archives, maybe run apt-get update or try with --fix-missing?

The key information here is:

E: Failed to fetch … Cannot initiate the connection

Or:

E: Failed to fetch ...  Connection timed out

Or:

Failed to fetch ...  Connection failed

That is, the system could not download some package files.

Cause of error:

  • you have an unstable internet connection and some files were not uploaded due to disconnections
  • some time passed between updating the application cache and downloading files, during which the packages in the repository managed to be updated – that is, you are trying to download old packages, and are no longer available on the server, as they are replaced by new versions. Such a situation is likely, especially if you need to upgrade many packages, and your Internet connection is slow.

To solve the problem, simply restart the update with the commands:

sudo apt update && sudo apt -y full-upgrade

This should completely correct the error.

During the update, a window or request appears that does not respond to clicks

Sometimes when updating, there are requests to the user, which may look like this:

Or look like this:

Since the update takes place in the console, what you see is a pseudo-graphic interface and use special buttons to work with it:

TAB – to navigate through the menu items

SPACE or ENTER – to select or deselect

Use the TAB key to go to the OK button and press ENTER to continue the update.

What to do if the program asks about updating the configuration file

With some updates of some packages, the structure of the configuration file changes. Sometimes the new file contains directives and settings that are necessary for the new version of the program, without which it cannot work.

To set up a program is almost always changing configuration files. The end result can be the result of long work with the configuration and a variety of tests. It may take hours or even days.

Therefore, if necessary, update the configuration, there is a dilemma:

  • do not update the config, as a result of which the new version will not work normally
  • update config and erase user configuration results

For this reason, the system asks you every time what needs to be done if the configuration file is updated with the program update?

If in reality you did not use this program, or the settings you have made are of no value to you, then always agree to update the configuration file. If the settings you have made are important to you, then:

  • refuse to update the configuration file
  • make a backup of your config, update the configuration file, and then make the necessary settings in it

For some packages, such as Tor, the configuration file is simply a set of comments in which no settings are active — for such files (if you have not changed them), the update is a mere formality.

Error: 1 404 Not Found [IP:

When updating, the following error may occur:

Ошб:1 http://http.kali.org/kali kali-rolling/main amd64 libboost-python1.67.0 amd64 1.67.0-10
404 Not Found [IP: 192.99.200.113 80]
Ошб:2 http://http.kali.org/kali kali-rolling/main amd64 libboost-random1.67.0 amd64 1.67.0-10
404 Not Found [IP: 192.99.200.113 80]

The key here is the ‘404 Not Found’ – that is, the package file was not found. The most common reason for this is an outdated cache with information about packages and links to download them.

Therefore, before updating packages, update the cache:

sudo apt update

Or use such a combined command that will update the cache and immediately start downloading and installing updated versions of packages:

sudo apt update && sudo apt -y full-upgrade

Error “E: Could not access the lock file /var/lib/dpkg/lock”

Perhaps the most common mistake when trying to update or install a new package:

Error “E: Could not access the lock file /var/lib/dpkg/lock”

All details on this error, as well as instructions for fixing here: https://miloserdov.org/?p=2016

W: An error occurred during the signature verification. The repository is not updated and the previous index files will be used. GPG error:

The process of updating packages, in addition to downloading and unpacking them, also includes checking their digital signatures. This verification ensures:

  • package integrity (that they were not damaged when downloading)
  • receiving them from a reliable source (these packages were not modified or created by unauthorized persons

The digital signature is delivered to the system also packaged in a package that is updated along with other packages of the system. If too much time has passed and the digital signature verification files are out of date, then a vicious circle occurs: you cannot update the packages in the system, as they pass the digital signature verification. You cannot update digital signature verification files because they are shipped as a package, and packages cannot be updated because…

In general, the problem is solved by one command that downloads and installs the actual file for checking the digital signature, details here: https://miloserdov.org/?p=893

Kali Linux update is delayed for the whole day

In a virtual machine, I encounter a slowdown in updating packages in Kali Linux. As a result, a big update can literally drag on for the whole day. Moreover, the process of unpacking downloaded updated packages takes the most time. Unpacking the exploitdb or metasploit-framework may take literally hours!

This is not normal – apparently some kind of bug.

Personally, I chose a rather non-standard solution for me – I have Kali Linux installed on a real (and not virtual) external USB drive, which I plug into VirtualBox and boot from it in a virtual machine. That is, without leaving the main system, I boot from an external disk. This is an excellent solution – the process of unpacking packages began to take a few minutes, but this is a little complicated method and it does not suit everyone.

If you want to work exclusively in VirtualBox and not connect an external USB drive, then as an option, you can remove two packages that take the most time to decompress, this is exploitdb and metasploit-framework. Moreover, the metasploit-framework package is a dependency for such tools as: armitage, commix, ghost phisher, jboss-autopwn, maltego-teeth, msfpc, set, u3-pwn, unicorn-magic. If you use any of these packages, then this method will not suit for you. If you do not need these packages, you can remove them with the command:

sudo apt remove exploitdb metasploit-framework armitage commix ghost-phisher jboss-autopwn kali-linux-full maltego-teeth msfpc set u3-pwn unicorn-magic

As a result, the update process will not hang for a whole day if a new version of exploitdb or metasploit-framework has been released.

What to do when the update is broken?

If your computer rebooted (power outages, computer froze, and other causes) when you run Kali Linux updates, an error may occur with the next update.

Start by running the command:

sudo apt-get install -f -y

Then try updating again.

sudo apt update && sudo apt -y full-upgrade

If it fails again, then repeat the command

sudo apt-get install -f -y

And again try to start the update.

If this does not help, then pay attention to which particular package causes the error? Remove this package. If the system writes that the package being removed is dependencies for other packages, then remove them all.

sudo apt remove PACKAGE_NAME

In this case, I recommend writing out the names of the packages to be deleted somewhere, in order to reinstall them and return the system to its original state.

After removing the problem package, try again a couple of times:

sudo apt-get install -f -y
sudo apt update && sudo apt -y full-upgrade

If the error disappears and the system is successfully updated, then return the remote packages.

Failed to fetch InRelease

I did not encounter such an error (apparently due to the fact that I always set the HTTPS protocol in the sources of applications), but this error is described here and shows how to fix it.

This error occurs when updating the program cache with the command:

apt update

Error example:

Err:1  http://http.kali.org/kali  kali-rolling InRelease
  403  Forbidden [IP: 192.99.200.113 80]
Reading package lists... Done
E: Failed to fetch  http://http.kali.org/kali/dists/kali-rolling/InRelease   403  Forbidden [IP: 192.99.200.113 80]
E: The repository 'http://http.kali.org/kali kali-rolling InRelease' is not signed.
N: Updating from such a repository can't be done securely, and is therefore disabled by default.
N: See apt-secure(8) manpage for repository creation and user configuration details.

By default, the /etc/apt/sources.list repository file already mentioned above contains an entry without the HTTPS protocol, but a mirror to which the apt package manager can only use the HTTPS protocol use only HTTP protocol). Due to this incompatibility, the mirror rejects the connection coming from the update manager.

The easiest way to fix this error is to replace HTTP with secure HTTPS. To do this, open the /etc/apt/sources.list file, and replace the line with:

deb http://http.kali.org/kali kali-rolling main non-free contrib

with:

deb https://http.kali.org/kali kali-rolling main non-free contrib

Than again start the cache updating — the problem should now completely disappear:

sudo apt update

The system occupies a lot of disk space

If the amount of used space increases and you cannot understand with which files your hard disk is filled, I recommend thinking about the file cache.

By default, all files downloaded for updating are not deleted. To remove them all, run the command:

sudo apt-get clean -y

Packages that are no longer used in the system after the upgrade can also accumulate; to remove them, issue the following command:

sudo apt autoremove

Recommended for you:

Leave a Reply

Your email address will not be published.

Looking for a job in IT. Details: https://miloserdov.org/?p=2900