Clean Ubuntu

Clean Ubuntu after an Upgrade

Posted by

We have done the upgrade from Bionic to Focal, now we need to clean the system a bit. First let’s check if the system is updated.

sudo apt update
sudo apt upgrade -y

Remove the unused packages

sudo apt autoremove -y

Now we will list the packages who are not installed from the available repositories.

[root@server]$ 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 still have an old kernel and the Zabbix agent. The major version in the repo is the same, so I will just reinstall it.

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 have also a lot of packages who are not completely uninstalled

[root@server]$ 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 clean system ready to use.

Leave a Reply

Your email address will not be published.