Cyberithub

Why do removed or uninstalled debian packages still shows in dpkg list?

Advertisements

It is often very confusing when you notice removed or uninstalled debian packages still shows in dpkg list. This usually happens when you remove the debian packages through sudo apt remove <package_name> command and after removal when you check the list of installed packages through dpkg -l command then the removed packages still be showing in the list. Something like this happened to me as well when I checked the list of installed packages after removing virtualbox application from my Ubuntu 20.04 LTS system, I noticed it was still showing in the list.

So before solving this problem I thought to write an article about this so that it will help you folks as well in case you are also struggling with this problem. In below section, I am going to explain the solution by giving an example of the problem I have faced in my system.

Advertisements

 

Why do removed or uninstalled debian packages still shows in dpkg list?

Why do removed or uninstalled debian packages still shows in dpkg list?

Also Read: How to Install Nmap on Ubuntu/Debian

So as I was explaining, after removing virtualbox package from my Ubuntu 20.04 LTS system, I noticed it was still showing in the dpkg -l command output as you can see below.

Advertisements
cyberithub@ubuntu:~$ dpkg -l | grep -i virtualbox
rc  virtualbox                                6.1.38-dfsg-3~ubuntu1.20.04.1   amd64           x86 virtualization solution - base binaries
rc  virtualbox-7.0                            7.0.12-159484~Ubuntu~focal      amd64           Oracle VM VirtualBox
rc  virtualbox-ext-pack                       6.1.38-1~ubuntu1.20.04.1        all             extra capabilities for VirtualBox, downloader.

To deal with this problem, first we need to understand the first column of dpkg output. Usually on the first column, you will see any of the below letter code :-

  • u - unknown
  • n - not installed
  • r - removed
  • c - only config files installed/remaining on the system

Depending on the letter code on the output, you have to understand the current package status and taken appropriate action accordingly. So as you can see in our case it is showing as rc which means virtualbox packages are removed, just config files are installed/remaining on the system. So to solve this problem, you have to remove the config files of virtualbox-7.0 using sudo apt purge virtualbox-7.0 --auto-remove command as shown below.

Advertisements
cyberithub@ubuntu:~$ sudo apt purge virtualbox-7.0 --auto-remove
Reading package lists... Done
Building dependency tree
Reading state information... Done
The following packages will be REMOVED:
virtualbox-7.0*
0 upgraded, 0 newly installed, 1 to remove and 6 not upgraded.
After this operation, 0 B of additional disk space will be used.
Do you want to continue? [Y/n] Y
(Reading database ... 261665 files and directories currently installed.)
Purging configuration files for virtualbox-7.0 (7.0.12-159484~Ubuntu~focal) ...
dpkg: warning: while removing virtualbox-7.0, directory '/usr/local/lib/python3.8/dist-packages' not empty so not removed

Similarly, to remove config files of virtualbox you have to run sudo apt purge virtualbox --auto-remove command as shown below.

cyberithub@ubuntu:~$ sudo apt purge virtualbox --auto-remove
Reading package lists... Done
Building dependency tree
Reading state information... Done
The following packages will be REMOVED:
virtualbox*
0 upgraded, 0 newly installed, 1 to remove and 6 not upgraded.
After this operation, 0 B of additional disk space will be used.
Do you want to continue? [Y/n] Y
(Reading database ... 261661 files and directories currently installed.)
Purging configuration files for virtualbox (6.1.38-dfsg-3~ubuntu1.20.04.1) ...
Processing triggers for systemd (245.4-4ubuntu3.22) ...

And finally to remove virtualbox-ext-pack, you have to run sudo apt purge virtualbox-ext-pack --auto-remove command as shown below.

Advertisements
cyberithub@ubuntu:~$ sudo apt purge virtualbox-ext-pack --auto-remove
Reading package lists... Done
Building dependency tree
Reading state information... Done
The following packages will be REMOVED:
virtualbox-ext-pack*
0 upgraded, 0 newly installed, 1 to remove and 6 not upgraded.
After this operation, 0 B of additional disk space will be used.
Do you want to continue? [Y/n] Y
(Reading database ... 261659 files and directories currently installed.)
Purging configuration files for virtualbox-ext-pack (6.1.38-1~ubuntu1.20.04.1) ...

After removing all the configuration files related to removed or uninstalled packages if you now check dpkg list again, this time you will notice that it will not show anything on the output as you can see below. This confirms that package is now fully removed and your problem is solved.

cyberithub@ubuntu:~$ dpkg -l | grep -i virtualbox

Leave a Comment