How To Update and Upgrade Ubuntu, Debian, Mint, and Kali? – POFTUT

How To Update and Upgrade Ubuntu, Debian, Mint, and Kali?

Ubuntu, Debian, Kali, and Mint use the same package management software named dpkg and apt. Updating OS is an important part of the system administration. We will look at how to update and upgrade deb based distributions.

Update Package Index

The first step to updating packages for Ubuntu, Debian, Kali, and Mint is updating the package index. The package index holds the most recent available packages from the repository and crosscheck with already installed packages. Than upgrade-able packages are created. We need root privileges to run this command. So we will use sudo command.

$ sudo apt update
Update Package Index
Update Package Index

List Upgradeable Packages

We can list currently upgrade-able packages. We will use apt list command with --upgradeable option.

$ sudo apt list --upgradeable

Upgrade All Packages

Now we have the required information to upgrade packages. We also know which packages will be upgraded by listing upgrade-able packages. We will upgrade with apt dist-upgrade which will upgrade and made version selection automatically. We required root privileges which are given by sudo.

$ sudo apt dist-upgrade -y

Upgrade Specific Package

In the previous example, we will upgrade all newly versioned packages. But in some cases like comp ability, this makes break comp-ability of existing software. We may need to upgrade specific packages. We will upgrade a specific package by giving the package name to the dist-upgrade command as a parameter. In this example, we will upgrade the package named tmux.

$ sudo apt dist-upgrade tmux

Update and Upgrade In Single Shot

In daily operations, we may need a fast and furious solution which will update and upgrade packages. I generally bind two commands together to make things faster and still reliable. If update operation fails upgrade will not start with the following command.

$ sudo apt update && sudo apt dist-upgrade -y
Update and Upgrade In Single Shot
Update and Upgrade In Single Shot

Clean Apt Package Cache

Over time the downloaded packages and package metadata will be held in the cache. This will take some space from our disk. We need to clean this cache periodically to get our disk space. We can clean our apt and dpkg cache with autoclean option.

$ sudo apt autoclean

Remove Unneeded and Unused Packages

Over time some packages are obsolete or not needed by their parents. These packages are not updated nor removed automatically. We can remove these unneeded packages with autoremove option like below.

$ sudo apt autoremove -y

LEARN MORE  How To Add New Repository To Apt In Linux?

Leave a Comment