sudo apt-get purge
和有什么区别sudo apt get remove --purge
?
肯定存在差异,或者两者都不应该存在。
答案1
它们是否应该同时存在或许是一个争论点。
然而 - 它们完全相同。
来自手册页apt-get
- 清除 对于要删除的内容,请使用 purge 而不是 remove。 星号(“*”)将显示在以下软件包旁边: 计划清除。remove --purge 相当于清除 命令。配置项:APT::Get::Purge。
关键部分是--purge 相当于 purge 命令
至于原因——我猜这是历史原因——
apt-get --purge remove
之前apt-get purge
看看旧公寓文档中引用了该命令的旧版本。较新的文档给出aptitude
&apt-get purge
示例。
为了保持一致性 - 最好不要删除旧接口 - 如果您有一个旧脚本 - 它今天仍然可以工作,因为接口命令仍然存在。
请注意,这并不能阻止 Gnome 弃用 api - 但那是另一个故事......
答案2
据我所知,没有,它们做完全相同的事情,删除包并尝试删除由这些包创建的任何配置文件。
基本上apt-get purge
是在之后实施的apt-get remove --purge
,但是旧的选项样式清除仍然存在。
答案3
它们是相同的,正如官方手册页中所述:remove --purge is equivalent to the purge command.
参见man apt
Ubuntu 在线手册页。我认为用法有所发展,并且两个命令都保留了下来;就像在其他程序中发生的情况一样,用法会发生变化,并且一种形式(即sudo apt-get purge
)会比另一种形式更受欢迎。但是,我仍在寻找这方面的参考资料并研究用法的历史,尽管在Debian 手册以及有关 apt-get 的文章Raphael Hertzog 的博客。
使用删除 vlc 的示例(尽管带有模拟标志),我们可以看到命令具有相同的结果;在两种情况下都-s
需要删除 vlc 使用的所有其他文件。sudo apt-get autoremove
1) sudo apt-get remove --purge
sudo apt-get -s remove --purge vlc
[sudo] password for mike:
Reading package lists... Done
Building dependency tree
Reading state information... Done
The following packages were automatically installed and are no longer required:
libdc1394-22 libxcb-keysyms1 libzvbi0 libxcb-xv0 libtar0 libass4 libdvbpsi7
libvlc5 vlc-nox libupnp3 libzvbi-common libxcb-randr0 libxcb-composite0
libiso9660-8 libkate1 vlc-plugin-notify vlc-plugin-pulse vlc-data
libdirac-encoder0 libvlccore5 libvcdinfo0 libebml3 libmatroska5
libsdl-image1.2
Use 'apt-get autoremove' to remove them.
The following packages will be REMOVED
vlc*
0 upgraded, 0 newly installed, 1 to remove and 0 not upgraded.
Purg vlc [2.0.3-0ubuntu0.12.04.1]
2)sudo apt-get purge
sudo apt-get -s purge vlc
Reading package lists... Done
Building dependency tree
Reading state information... Done
The following packages were automatically installed and are no longer required:
libdc1394-22 libxcb-keysyms1 libzvbi0 libxcb-xv0 libtar0 libass4 libdvbpsi7
libvlc5 vlc-nox libupnp3 libzvbi-common libxcb-randr0 libxcb-composite0
libiso9660-8 libkate1 vlc-plugin-notify vlc-plugin-pulse vlc-data
libdirac-encoder0 libvlccore5 libvcdinfo0 libebml3 libmatroska5
libsdl-image1.2
Use 'apt-get autoremove' to remove them.
The following packages will be REMOVED
vlc*
0 upgraded, 0 newly installed, 1 to remove and 0 not upgraded.
Purg vlc [2.0.3-0ubuntu0.12.04.1]
答案4
我刚刚尝试使用apt
而不是apt-get
来删除旧内核。该remove
命令删除了它们,但它们仍显示为大小为 0B 的包。该--purge remove
选项实际上使它们停止显示。
:~$ uname -r
5.19.0-41-generic
:~$ dpkg --get-selections | grep "linux-image-[[:digit:]].*" | tr "\t" ";" | cut -d ";" -f1
linux-image-5.19.0-38-generic
linux-image-5.19.0-40-generic
linux-image-5.19.0-41-generic
:~$ sudo apt remove linux-image-5.19.0-38-generic linux-image-5.19.0-40-generic
Reading package lists... Done
Building dependency tree... Done
Reading state information... Done
Package 'linux-image-5.19.0-38-generic' is not installed, so not removed
The following packages will be REMOVED
linux-image-5.19.0-40-generic
0 to upgrade, 0 to newly install, 1 to remove and 1 not to upgrade.
After this operation, 12.2 MB disk space will be freed.
Do you want to continue? [Y/n] Y
(Reading database ... 202847 files and directories currently installed.)
Removing linux-image-5.19.0-40-generic (5.19.0-40.41~22.04.1) ...
I: /boot/vmlinuz.old is now a symlink to vmlinuz-5.19.0-41-generic
I: /boot/initrd.img.old is now a symlink to initrd.img-5.19.0-41-generic
/etc/kernel/postrm.d/initramfs-tools:
update-initramfs: Deleting /boot/initrd.img-5.19.0-40-generic
/etc/kernel/postrm.d/zz-update-grub:
Sourcing file `/etc/default/grub'
Sourcing file `/etc/default/grub.d/init-select.cfg'
Generating grub configuration file ...
Found linux image: /boot/vmlinuz-5.19.0-41-generic
Found initrd image: /boot/initrd.img-5.19.0-41-generic
Memtest86+ needs a 16-bit boot, that is not available on EFI, exiting
Warning: os-prober will be executed to detect other bootable partitions.
Its output will be used to detect bootable binaries on them and create new boot entries.
Found Windows Boot Manager on /dev/nvme0n1p1@/EFI/Microsoft/Boot/bootmgfw.efi
Adding boot menu entry for UEFI Firmware Settings ...
done
:~$ dpkg --get-selections | grep "linux-image-[[:digit:]].*" | tr "\t" ";" | cut -d ";" -f1
linux-image-5.19.0-38-generic
linux-image-5.19.0-40-generic
linux-image-5.19.0-41-generic
:~$ sudo apt --purge remove linux-image-5.19.0-38-generic linux-image-5.19.0-40-generic
Reading package lists... Done
Building dependency tree... Done
Reading state information... Done
The following packages were automatically installed and are no longer required:
linux-headers-5.19.0-40-generic linux-hwe-5.19-headers-5.19.0-40 linux-modules-5.19.0-40-generic linux-modules-extra-5.19.0-40-generic
Use 'sudo apt autoremove' to remove them.
The following packages will be REMOVED
linux-image-5.19.0-38-generic* linux-image-5.19.0-40-generic*
0 to upgrade, 0 to newly install, 2 to remove and 1 not to upgrade.
After this operation, 0 B of additional disk space will be used.
Do you want to continue? [Y/n] Y
(Reading database ... 202843 files and directories currently installed.)
Purging configuration files for linux-image-5.19.0-40-generic (5.19.0-40.41~22.04.1) ...
rmdir: failed to remove '/lib/modules/5.19.0-40-generic': Directory not empty
Purging configuration files for linux-image-5.19.0-38-generic (5.19.0-38.39~22.04.1) ...
:~$ dpkg --get-selections | grep "linux-image-[[:digit:]].*" | tr "\t" ";" | cut -d ";" -f1
linux-image-5.19.0-41-generic