3

I am running Ubuntu 20.04LTS. When I search for virtualbox in my packages, it shows a number of packages.

~$ apt list | grep virtualbox

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

boinc-virtualbox/focal 7.16.6+dfsg-1 amd64
unity-scope-virtualbox/focal,focal 0.1+13.10.20130723-0ubuntu2 all
virtualbox-dkms/focal-updates 6.1.10-dfsg-1~ubuntu1.20.04.1 amd64
virtualbox-ext-pack/focal-updates,focal-updates 6.1.10-1~ubuntu1.20.04.1 all
virtualbox-guest-additions-iso/focal-updates,focal-updates 6.1.10-1~ubuntu1.20.04.1 all
virtualbox-guest-dkms-hwe/focal-updates,focal-updates 6.1.10-dfsg-1~ubuntu1.20.04.1 all
virtualbox-guest-dkms/focal-updates,focal-updates 6.1.10-dfsg-1~ubuntu1.20.04.1 all
virtualbox-guest-source-hwe/focal-updates,focal-updates 6.1.10-dfsg-1~ubuntu1.20.04.1 all
virtualbox-guest-source/focal-updates,focal-updates 6.1.10-dfsg-1~ubuntu1.20.04.1 all
virtualbox-guest-utils-hwe/focal-updates 6.1.10-dfsg-1~ubuntu1.20.04.1 amd64
virtualbox-guest-utils/focal-updates 6.1.10-dfsg-1~ubuntu1.20.04.1 amd64
virtualbox-guest-x11-hwe/focal-updates 6.1.10-dfsg-1~ubuntu1.20.04.1 amd64
virtualbox-guest-x11/focal-updates 6.1.10-dfsg-1~ubuntu1.20.04.1 amd64
virtualbox-qt/focal-updates,now 6.1.10-dfsg-1~ubuntu1.20.04.1 amd64 [residual-config]
virtualbox-source/focal-updates 6.1.10-dfsg-1~ubuntu1.20.04.1 amd64
virtualbox/focal-updates,now 6.1.10-dfsg-1~ubuntu1.20.04.1 amd64 [residual-config]

However, when I try to remove either of them, it says that that package is not installed, so not removed.

$ sudo apt-get remove virtualbox-dkms

Reading package lists... Done
Building dependency tree       
Reading state information... Done
Package 'virtualbox-dkms' is not installed, so not removed
0 upgraded, 0 newly installed, 0 to remove and 0 not upgraded.

--- 
~$ sudo apt-get remove virtualbox-source

Reading package lists... Done
Building dependency tree       
Reading state information... Done
Package 'virtualbox-source' is not installed, so not removed
0 upgraded, 0 newly installed, 0 to remove and 0 not upgraded.

---
~$ sudo apt-get remove virtualbox-guest*

Reading package lists... Done
Building dependency tree       
Reading state information... Done
Note, selecting 'virtualbox-guest-utils' for glob 'virtualbox-guest*'
Note, selecting 'virtualbox-guest-modules' for glob 'virtualbox-guest*'
Note, selecting 'virtualbox-guest-additions-iso' for glob 'virtualbox-guest*'
Note, selecting 'virtualbox-guest-dkms' for glob 'virtualbox-guest*'
Note, selecting 'virtualbox-guest-dkms-hwe' for glob 'virtualbox-guest*'
Note, selecting 'virtualbox-guest-modules-hwe' for glob 'virtualbox-guest*'
Note, selecting 'virtualbox-guest-x11-hwe' for glob 'virtualbox-guest*'
Note, selecting 'virtualbox-guest-source' for glob 'virtualbox-guest*'
Note, selecting 'virtualbox-guest-source-hwe' for glob 'virtualbox-guest*'
Note, selecting 'virtualbox-guest-utils-hwe' for glob 'virtualbox-guest*'
Note, selecting 'virtualbox-guest-x11' for glob 'virtualbox-guest*'
Package 'virtualbox-guest-modules-hwe' is not installed, so not removed
Package 'virtualbox-guest-additions-iso' is not installed, so not removed
Package 'virtualbox-guest-dkms' is not installed, so not removed
Package 'virtualbox-guest-dkms-hwe' is not installed, so not removed
Package 'virtualbox-guest-source' is not installed, so not removed
Package 'virtualbox-guest-source-hwe' is not installed, so not removed
Package 'virtualbox-guest-utils' is not installed, so not removed
Package 'virtualbox-guest-utils-hwe' is not installed, so not removed
Package 'virtualbox-guest-x11' is not installed, so not removed
Package 'virtualbox-guest-x11-hwe' is not installed, so not removed
0 upgraded, 0 newly installed, 0 to remove and 0 not upgraded.

Could someone help me understand what's going on here? I am fairly new to Linux. Loving it but still get confused by such things. Thanks!

Update: I get different results when using dpkg and apt list as shown below:

~$ dpkg --list | grep -i virtualbox
rc  virtualbox                                 6.1.10-dfsg-1~ubuntu1.20.04.1         amd64        x86 virtualization solution - base binaries
rc  virtualbox-qt                              6.1.10-dfsg-1~ubuntu1.20.04.1         amd64        x86 virtualization solution - Qt based user interface

~$ apt list --installed | grep virtualbox
WARNING: apt does not have a stable CLI interface. Use with caution in scripts.

1 Answer 1

6

apt list | grep virtualbox lists the available packages in your software sources that can be installed with apt. You need to run the following command to list the packages that are currently installed with apt:

apt list --installed | grep virtualbox

Please note that this command will return an error message if you try to run it with apt-get instead of apt.

This command will return a shorter list of packages because the results of sudo apt remove virtualbox-dkms virtualbox-source virtualbox-guest* show that many of the packages that are listed in the results are not currently installed.

The results of dpkg --list | grep -i virtualbox show that these two packages are manually installed: virtualbox and virtualbox-qt. You can uninstall these two packages with the following command:

sudo dpkg --purge virtualbox virtualbox-qt

The packages are selected to be purged (i.e. we want to remove everything from system directories, even configuration files). This would be a good command to run if you are planning to install a more recent version of VirtualBox.

9
  • 2
    Maybe apt list --installed | grep virtualbox would be simpler? And add link to man-page for learning curve.
    – N0rbert
    Jul 31, 2020 at 9:36
  • I usually use dpkg to achieve this e.g. dpkg --list | grep -i virtualbox, just another way of doing things. Cheers!
    – haralambov
    Jul 31, 2020 at 9:40
  • @haralambov That has the same problem as the original pipeline, though. It lists all available packages, not only the ones that are installed. For this, you could add a second grep that checks for the ii that indicates the package is installed: dpkg --list | grep -i virtualbox | grep ^ii Jul 31, 2020 at 9:44
  • 1
    @haralambov I updated my original post with the results for dpkg. I seem to be getting different results as compared to apt list --installed. Jul 31, 2020 at 9:54
  • 1
    @LearnerYoda apt works on a different layer than dpkg does. I've explained the basics in a different answer. So if you downloaded a *.deb file and (manually) installed it with dpkg -i, it will be listed by dpkg --list. But it won't be listed by apt list, because it didn't come from a repository apt knows about. Jul 31, 2020 at 10:05

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .