Clean Ubuntu after an upgrade to Ubuntu 22.04

Clean Ubuntu after an upgrade Ubuntu 22.04

Clean Ubuntu after an upgrade to Ubuntu 22.04, We just upgraded Ubuntu from Ubuntu 20.04 focal to Ubuntu 22.04 jammy, now we need to clean up our system a bit. First of all, let’s check that the system is up-to-date.

sudo apt update
sudo apt upgrade -y

Let’s uninstall unnecessary packages.

sudo apt autoremove -y

There are packages left from the old version, let’s list all the packages not available in the Focal .

[[email protected]]$ apt list --installed | grep installed,local

WARNING: apt does not have a stable CLI interface. Use with caution in scripts.

linux-image-4.15.0-96-generic/now 4.15.0-96.97 amd64 [installed,local]
linux-modules-4.15.0-96-generic/now 4.15.0-96.97 amd64 [installed,local]
linux-modules-extra-4.15.0-96-generic/now 4.15.0-96.97 amd64 [installed,local]
zabbix-agent/now 1:4.0.19-1+bionic amd64 [installed,local]

As we can see I have an old kernel and Zabbix which are still there. For Zabbix, the version in the Ubuntu is similar, a reinstallation will suffice.

sudo apt remove zabbix-agent -y
sudo apt install zabbix-agent -y

Let’s remove the old kernel

sudo apt remove linux-image-4.15.0-96-generic linux-modules-4.15.0-96-generic linux-modules-extra-4.15.0-96-generic

We also have quite a few packages that haven’t been completely uninstalled.

[[email protected]]$ dpkg --list |grep "^rc" | wc -l

Let’s remove them

dpkg --list |grep "^rc" | cut -d " " -f 3 | xargs dpkg --purge

We now have a much cleaner system ready to use 🙂

Be the first to comment

Leave a Reply

Your email address will not be published.