我正在运行 Ubuntu 20.04LTS。当我在软件包中搜索 virtualbox 时,它会显示许多软件包。
~$ 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]
但是,当我尝试删除其中任何一个时,它说该包未安装,因此未删除。
$ 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.
有人能帮我理解一下这里发生了什么吗?我对 Linux 还很陌生。喜欢它,但仍然对这些东西感到困惑。谢谢!
更新:使用dpkg
和时我得到了不同的结果,apt list
如下所示:
~$ 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
apt list | grep virtualbox
列出软件源中可用的软件包可以安装使用 apt。您需要运行以下命令来列出当前使用 apt 安装的软件包:
apt list --installed | grep virtualbox
请注意,如果您尝试使用 apt-get 而不是 apt 来运行该命令,该命令将返回错误消息。
此命令将返回较短的包列表,因为结果sudo apt remove virtualbox-dkms virtualbox-source virtualbox-guest*
显示结果中列出的许多包当前尚未安装。
结果dpkg --list | grep -i virtualbox
显示这两个包是手动安装的:虚拟盒和virtualbox-qt。你可以用以下命令卸载这两个包:
sudo dpkg --purge virtualbox virtualbox-qt
选择要清除的软件包(即我们要从系统目录中删除所有内容,甚至配置文件)。如果您计划安装较新版本的 VirtualBox,这将是一个不错的命令。