Regular Updates and Cleaning Kali Linux System
Kali Linux is a rolling distribution, that means it continuously updates in all areas of the operating system, including the Linux kernel, the desktop environment, all utilities and all applications. So we need to update it frequently to stay updated always.
Not only that, due to update regularly some old packages of applications are kept on our system as a junk. These older files are not so much harmful but they might slow down our system. So we need to clean them on regular basis.
Updating & Upgrading Kali Linux
There are various types of updates we can do like normal update, full upgrade, distribution upgrade.
Updating Kali Linux
Update can be simply done by following command:
The above command will update the package lists for upgrades for packages that need upgrading, as well as new packages that have just come to the Kali Linux repositories. As we can see in the following screenshot:
In the above screenshot we can see that we have already updated our system. One thing to remember that this updates the list of available packages and their versions, but it does not install or upgrade any packages. We can actually install them by using upgrade.
Upgrading Kali Linux
Where update updates the list of available packages but didn’t install them, upgrade actually installs newer versions of the packages we have. After updating the lists, the package manager knows about available updates for the software you have installed. That’s why we need to run update before upgrading.
To upgrading Kali Linux we need to run following command on our Kali Linux system:
As we can see in the following screenshot:
In the above screenshot we can see that the upgrade is running. It will take some time depending our internet connection and system performance. Unlike Windows we can cancel it anytime and resume it by applying the same command.
Where sudo apt upgrade -y command installs all and doesn’t remove any packages and skips upgrading old packages if removal is needed, sudo apt full-upgrade -y command removes old packages if needed to perform the upgrade of packages to their latest versions.
The output of the above command shown in the following screenshot:
sudo apt full-upgrade can be run after sudo apt update -y command but sudo apt update -y is considered more safe then sudo apt full-upgrade -y command. But anyways don’t panic it doesn’t harm our system badly. To know the very detailed difference in these commands please read this article.
Similar to sudo apt-get upgrade command, the sudo apt-get dist-upgrade also upgrades the packages. In addition to this, it also handles changing dependencies with the latest versions of the package. It intelligently resolves the conflict among package dependencies and tries to upgrade the most significant packages at the expense of less significant ones, if required. Unlike sudo apt-get upgrade command, the sudo apt-get dist-upgrade is proactive and it installs new packages or removes existing ones on its own in order to complete the upgrade.
The above command will upgrade our distribution totally.
Cleaning Kali Linux
We can clean our no-longer needed packages by using following command on our Kali Linux terminal:
In the following screenshot we can see the output of this command.
In the above screenshot we can see that 19 MB of our disk space is cleared and some packages are removed. Use of this command is safe and should not cause problems.
Each program update, package files are downloaded to the package cache. After the update, downloaded files (you can call them installation files) are not deleted, and gradually the package cache grows to large sizes. This was done intentionally with the idea that if after the next update you find that the new package has problems and the old version is no longer available in the online repository, then you can roll back to the old version by installing it from a file saved in the package cache.
For rolling distributions, the cache grows very quickly, and if we are not qualified enough to roll back to the old version using the installation package which is stored in the cache, then for you these hundreds of megabytes or even several gigabytes are a waste of space on our hard drive. Therefore, from time to time we can execute following commands:
The sudo apt clean -y command cleans the local repository from received package files. It removes everything except the lock file from /var/cache/apt/archives/ and /var/cache/apt/archives/partial/.
Like sudo apt clean -y command, sudo apt autoclean -y cleans downloaded package files from the local repository. The only difference is that it only removes package files that can no longer be downloaded and are largely useless.
This allows us to maintain the cache for a long period without growing too much.
The following command is not directly related to cleaning, but helps maintain our Kali Linux system health.
The -f or –fix-broken flag tries to make normal a system by repairing broken dependencies. This option, when used with install/remove, may skip any packages to allow APT to find a likely solution. If packages are listed, this should completely fix the problem.
This is everything to this article, hope now we got a clear idea about “How to update Kali Linux” and “How to clean Kali Linux”.
Love our articles? Make sure to follow us on Twitter and GitHub, we post article updates there. To join our KaliLinuxIn family, join our Telegram Group. We are trying to build a community for Linux and Cybersecurity. For anything we always happy to help everyone on the comment section. As we know our comment section is always open to everyone. We read each and every comment and we always reply.