将 Ubuntu 重置回 ubuntu-server pristine?

将 Ubuntu 重置回 ubuntu-server pristine?

我有一个运行 Ubuntu 桌面的 Ubuntu 盒子,已经从 18.04 升级到 20.04 再升级到 22.04。

我想将其转换为 Ubuntu 服务器。

我可以运行哪些命令来将其(按包)重置为原始的 Ubuntu 服务器?

请注意,这是不是这与简单地卸载 ubuntu-desktop(此站点上有很多答案)相同,因为这会留下大量其他软件包。例如:如果我在某个时候安装了 VLC,其中包括一些依赖的 GUI 软件包。我想删除它们(以及 VLC,例如)。

答案1

有一种非常快速简便的方法可以从 Ubuntu 系统中移除几乎所有图形内容,从而恢复为仅使用命令行的系统。我已经这样做过几次了,而且很可靠。但是,可能会留下一些奇怪的库或应用程序,但我也会向您展示如何删除它们。

关键部分是删除绝大多数应用程序所依赖的底层 X11 库包。我通常只选择一个libxrender1

但是,根据您安装的内容,您可能还需要删除libice6libx11-6libx11-datalibxau6libxext6libxdmcp6libxi6、和。libxmuu1libxpm4libxtst6x11-common

例如,下面是如果您只删除一个会发生的情况,但我可能建议也列出上述所有内容。这不会花很长时间,并且除了图形应用程序和库之外不会删除任何其他内容。

sudo apt autoremove libxrender

你会发现它会想要删除一个很多软件包。我刚刚在这里启动了一个旧的 20.04 VM(它有一些待处理的更新,因此输出略有不同),但以下是您将看到的内容 - 或类似内容。

$ sudo apt autoremove libxrender1
Reading package lists... Done
Building dependency tree... Done
Reading state information... Done
The following additional packages will be installed:
  foomatic-filters printer-driver-foo2zjs printer-driver-foo2zjs-common python3-distupgrade ubuntu-release-upgrader-core
Suggested packages:
  hannah-foo2zjs psutils tix tk
Recommended packages:
  paps | cups | enscript | a2ps poppler-utils colord cups
The following packages will be REMOVED
  acl adwaita-icon-theme aisleriot apg apport apport-gtk apport-symptoms aptdaemon aptdaemon-data apturl apturl-common avahi-utils baobab bluez-cups bubblewrap cheese
  cheese-common colord colord-data cpp cpp-11 cups cups-browsed cups-core-drivers cups-daemon cups-filters cups-filters-core-drivers cups-ipp-utils cups-pk-helper
  cups-server-common dconf-cli deja-dup docbook-xml duplicity enchant-2 eog evince evince-common evolution-data-server evolution-data-server-common file-roller gcc-11-base
  gcr gdb gdm3 gedit gedit-common genisoimage geoclue-2.0 gir1.2-accountsservice-1.0 gir1.2-adw-1 gir1.2-atk-1.0 gir1.2-atspi-2.0 gir1.2-dbusmenu-glib-0.4 gir1.2-dee-1.0
  gir1.2-freedesktop gir1.2-gck-1 gir1.2-gcr-3 gir1.2-gdesktopenums-3.0 gir1.2-gdkpixbuf-2.0 gir1.2-gdm-1.0 gir1.2-geoclue-2.0 gir1.2-gnomebluetooth-3.0
  gir1.2-gnomedesktop-3.0 gir1.2-goa-1.0 gir1.2-graphene-1.0 gir1.2-gst-plugins-base-1.0 gir1.2-gstreamer-1.0 gir1.2-gtk-3.0 gir1.2-gtk-4.0 gir1.2-gtksource-4
  gir1.2-gudev-1.0 gir1.2-gweather-3.0 gir1.2-handy-1 gir1.2-harfbuzz-0.0 gir1.2-ibus-1.0 gir1.2-javascriptcoregtk-4.0 gir1.2-json-1.0 gir1.2-mutter-10 gir1.2-nm-1.0
  gir1.2-nma-1.0 gir1.2-notify-0.7 gir1.2-packagekitglib-1.0 gir1.2-pango-1.0 gir1.2-peas-1.0 gir1.2-polkit-1.0 gir1.2-rb-3.0 gir1.2-rsvg-2.0 gir1.2-snapd-1 gir1.2-soup-2.4
  gir1.2-totem-1.0 gir1.2-totemplparser-1.0 gir1.2-udisks-2.0 gir1.2-unity-7.0 gir1.2-upowerglib-1.0 gir1.2-vte-2.91 gir1.2-webkit2-4.0 gir1.2-wnck-3.0 gjs gkbd-capplet
  gnome-bluetooth gnome-bluetooth-3-common gnome-bluetooth-common gnome-calculator gnome-calendar gnome-characters gnome-control-center gnome-control-center-faces
  gnome-desktop3-data gnome-disk-utility gnome-font-viewer gnome-initial-setup gnome-keyring gnome-keyring-pkcs11 gnome-logs gnome-mahjongg gnome-mines gnome-online-accounts
  gnome-power-manager gnome-remote-desktop gnome-session-bin gnome-session-canberra gnome-session-common gnome-settings-daemon gnome-settings-daemon-common gnome-shell
  gnome-shell-common gnome-shell-extension-appindicator gnome-shell-extension-desktop-icons-ng gnome-shell-extension-ubuntu-dock gnome-startup-applications gnome-sudoku
  gnome-system-monitor gnome-terminal gnome-terminal-data gnome-themes-extra gnome-themes-extra-data gnome-todo gnome-todo-common gnome-user-docs gnome-video-effects
  grilo-plugins-0.3-base gstreamer1.0-clutter-3.0 gstreamer1.0-gl gstreamer1.0-gtk3 gstreamer1.0-pipewire gstreamer1.0-plugins-base gstreamer1.0-plugins-good
  gstreamer1.0-pulseaudio gstreamer1.0-x gtk-update-icon-cache gtk2-engines-murrine gtk2-engines-pixbuf guile-2.2-libs hicolor-icon-theme hplip hplip-data
  humanity-icon-theme hunspell-en-us ibus ibus-data ibus-gtk ibus-gtk3 ibus-gtk4 ibus-table iio-sensor-proxy ipp-usb language-selector-gnome libaa1 libabsl20210324
  libabw-0.1-1 libadwaita-1-0 libatkmm-1.6-1v5 libatomic1 libavahi-ui-gtk3-0 libavc1394-0 libayatana-appindicator3-1 libayatana-ido3-0.4-0 libayatana-indicator3-7
  libbabeltrace1 libboost-filesystem1.74.0 libboost-iostreams1.74.0 libboost-locale1.74.0 libboost-regex1.74.0 libboost-thread1.74.0 libc6-dbg libcaca0 libcairo-gobject-perl
  libcairo-gobject2 libcairo-perl libcairo-script-interpreter2 libcairo2 libcairomm-1.0-1v5 libcamel-1.2-63 libcanberra-gtk3-0 libcanberra-gtk3-module libcanberra-pulse
  libcanberra0 libcdparanoia0 libcdr-0.1-1 libcheese-gtk25 libcheese8 libclucene-contribs1v5 libclucene-core1v5 libclutter-1.0-0 libclutter-1.0-common libclutter-gst-3.0-0
  libclutter-gtk-1.0-0 libcogl-common libcogl-pango20 libcogl-path20 libcogl20 libcolamd2 libcolord-gtk1 libcolord2 libcolorhug2 libcue2 libcupsimage2 libdatrie1
  libdazzle-1.0-0 libdazzle-common libdbusmenu-glib4 libdbusmenu-gtk3-4 libdebuginfod-common libdebuginfod1 libdee-1.0-4 libdjvulibre-text libdjvulibre21
  libdmapsharing-3.0-2 libdrm-amdgpu1 libdrm-intel1 libdrm-nouveau2 libdrm-radeon1 libdv4 libe-book-0.1-1 libebackend-1.2-10 libebook-1.2-20 libebook-contacts-1.2-3
  libecal-2.0-1 libedata-book-1.2-26 libedata-cal-2.0-1 libedataserver-1.2-26 libedataserverui-1.2-3 libegl-mesa0 libegl1 libenchant-2-2 libeot0 libepoxy0 libepubgen-0.1-1
  libetonyek-0.1-1 libevdocument3-4 libevent-2.1-7 libevview3-3 libexempi8 libexiv2-27 libexttextcat-2.0-0 libextutils-depends-perl libffi7 libfontembed1 libfontenc1
  libfreehand-0.1-1 libfreerdp-client2-2 libfreerdp-server2-2 libfreerdp2-2 libgail-common libgail18 libgbm1 libgc1 libgcr-ui-3-1 libgdm1 libgee-0.8-2 libgeoclue-2-0
  libgeocode-glib0 libgexiv2-2 libgif7 libgjs0g libgl1 libgl1-amber-dri libgl1-mesa-dri libglapi-mesa libgles2 libglib-object-introspection-perl libglib-perl
  libglibmm-2.4-1v5 libglu1-mesa libglvnd0 libglx-mesa0 libglx0 libgnome-autoar-0-0 libgnome-bg-4-1 libgnome-bluetooth-3.0-13 libgnome-bluetooth13 libgnome-desktop-3-19
  libgnome-desktop-4-1 libgnome-games-support-1-3 libgnome-games-support-common libgnome-todo libgnomekbd-common libgnomekbd8 libgoa-backend-1.0-1 libgom-1.0-0 libgpgmepp6
  libgpod-common libgpod4 libgraphene-1.0-0 libgraphite2-3 libgrilo-0.3-0 libgsf-1-114 libgsf-1-common libgsound0 libgspell-1-2 libgspell-1-common libgssdp-1.2-0
  libgstreamer-gl1.0-0 libgstreamer-plugins-good1.0-0 libgtk-3-0 libgtk-3-bin libgtk-3-common libgtk-4-1 libgtk-4-bin libgtk-4-common libgtk2.0-0 libgtk2.0-bin
  libgtk2.0-common libgtk3-perl libgtkmm-3.0-1v5 libgtksourceview-4-0 libgtksourceview-4-common libgtop-2.0-11 libgtop2-common libgupnp-1.2-1 libgupnp-av-1.0-3
  libgupnp-dlna-2.0-4 libgweather-3-16 libgweather-common libgxps2 libhandy-1-0 libharfbuzz-icu0 libharfbuzz0b libhpmud0 libhunspell-1.7-0 libhyphen0 libibus-1.0-5
  libiec61883-0 libieee1284-3 libimagequant0 libinput-bin libinput10 libipt2 libisl23 libjavascriptcoregtk-4.0-18 libkpathsea6 liblirc-client0 libllvm15 liblouisutdml-bin
  liblouisutdml-data liblouisutdml9 liblua5.3-0 libmanette-0.2-0 libmediaart-2.0-0 libmessaging-menu0 libmhash2 libminiupnpc17 libmozjs-91-0 libmp3lame0 libmpc3 libmpfr6
  libmpg123-0 libmspub-0.1-1 libmtdev1 libmutter-10-0 libmwaw-0.3-3 libmythes-1.2-0 libnatpmp1 libnautilus-extension1a libnma-common libnma0 libodfgen-0.1-1 libopengl0
  liborcus-0.17-0 liborcus-parser-0.17-0 libpagemaker-0.0-0 libpango-1.0-0 libpangocairo-1.0-0 libpangoft2-1.0-0 libpangomm-1.4-1v5 libpangoxft-1.0-0 libpciaccess0
  libpeas-1.0-0 libpeas-common libphonenumber8 libpipewire-0.3-0 libpipewire-0.3-common libpipewire-0.3-modules libpkcs11-helper1 libpoppler-cpp0v5 libpoppler-glib8
  libpoppler118 libprotobuf23 libpulse-mainloop-glib0 libqpdf28 libqqwing2v5 libraptor2-0 libraqm0 librasqal3 libraw1394-11 libraw20 librdf0 libreoffice-base-core
  libreoffice-calc libreoffice-core libreoffice-draw libreoffice-gnome libreoffice-gtk3 libreoffice-impress libreoffice-math libreoffice-ogltrans libreoffice-pdfimport
  libreoffice-writer librest-0.7-0 librevenge-0.0-0 librhythmbox-core10 librsvg2-2 librsvg2-common librsync2 librygel-core-2.6-2 librygel-db-2.6-2 librygel-renderer-2.6-2
  librygel-server-2.6-2 libsane-common libsane-hpaio libsane1 libsensors-config libsensors5 libsgutils2-2 libshout3 libsigc++-2.0-0v5 libsnmp-base libsnmp40 libsodium23
  libsoup-gnome2.4-1 libsource-highlight-common libsource-highlight4v5 libspa-0.2-modules libspectre1 libspeex1 libstartup-notification0 libsuitesparseconfig5 libsynctex2
  libsysmetrics1 libtag1v5 libtag1v5-vanilla libthai-data libthai0 libtheora0 libtotem-plparser-common libtotem-plparser18 libtotem0 libtracker-sparql-3.0-0 libtwolame0
  libunity-protocol-private0 libunity-scopes-json-def-desktop libunity9 libv4l-0 libv4lconvert0 libvisio-0.1-1 libvisual-0.4-0 libvncclient1 libvncserver1 libvorbisfile3
  libvpx7 libvte-2.91-0 libvte-2.91-common libvulkan1 libwacom-bin libwacom-common libwacom9 libwavpack1 libwayland-client0 libwayland-cursor0 libwayland-egl1
  libwayland-server0 libwebkit2gtk-4.0-37 libwebpdemux2 libwebpmux3 libwhoopsie-preferences0 libwinpr2-2 libwnck-3-0 libwnck-3-common libwoff1 libwpd-0.10-10 libwpg-0.3-3
  libwps-0.4-4 libxatracker2 libxaw7 libxcb-dri2-0 libxcb-dri3-0 libxcb-glx0 libxcb-icccm4 libxcb-image0 libxcb-keysyms1 libxcb-present0 libxcb-randr0 libxcb-render-util0
  libxcb-render0 libxcb-res0 libxcb-shape0 libxcb-shm0 libxcb-sync1 libxcb-util1 libxcb-xfixes0 libxcb-xkb1 libxcb-xv0 libxcomposite1 libxcursor1 libxcvt0 libxdamage1
  libxfixes3 libxfont2 libxft2 libxinerama1 libxkbcommon-x11-0 libxkbcommon0 libxkbfile1 libxkbregistry0 libxklavier16 libxmlsec1 libxmlsec1-nss libxmu6 libxrandr2
  libxrender1 libxres1 libxshmfence1 libxslt1.1 libxss1 libxv1 libxvmc1 libxxf86dga1 libxxf86vm1 libyajl2 libyelp0 lp-solve media-player-info mesa-vulkan-drivers
  mobile-broadband-provider-info mousetweaks mutter mutter-common nautilus nautilus-data nautilus-extension-gnome-terminal nautilus-share network-manager-gnome
  network-manager-openvpn network-manager-openvpn-gnome network-manager-pptp-gnome openvpn orca p11-kit p11-kit-modules patch pinentry-gnome3 pipewire pipewire-bin
  pipewire-media-session plymouth-label plymouth-theme-spinner poppler-utils power-profiles-daemon printer-driver-hpcups printer-driver-postscript-hp printer-driver-splix
  python3-apport python3-aptdaemon python3-aptdaemon.gtk3widgets python3-bcrypt python3-brlapi python3-cairo python3-certifi python3-chardet python3-cups python3-cupshelpers
  python3-dateutil python3-debconf python3-debian python3-defer python3-fasteners python3-future python3-gi-cairo python3-ibus-1.0 python3-idna python3-lib2to3
  python3-lockfile python3-louis python3-macaroonbakery python3-mako python3-markupsafe python3-monotonic python3-nacl python3-olefile python3-paramiko python3-pexpect
  python3-pil python3-problem-report python3-protobuf python3-ptyprocess python3-pyatspi python3-pymacaroons python3-renderpm python3-reportlab python3-reportlab-accel
  python3-requests python3-rfc3339 python3-software-properties python3-speechd python3-systemd python3-tz python3-uno python3-urllib3 python3-xdg remmina remmina-common
  remmina-plugin-rdp remmina-plugin-secret remmina-plugin-vnc rhythmbox rhythmbox-data rhythmbox-plugin-alternative-toolbar rhythmbox-plugins rygel sane-airscan sane-utils
  seahorse sgml-base sgml-data shotwell shotwell-common simple-scan software-properties-common software-properties-gtk sound-theme-freedesktop spice-vdagent ssl-cert
  switcheroo-control system-config-printer system-config-printer-common system-config-printer-udev thunderbird thunderbird-gnome-support thunderbird-locale-en
  thunderbird-locale-en-gb thunderbird-locale-en-us totem totem-common totem-plugins tracker tracker-extract tracker-miner-fs transmission-common transmission-gtk
  ubuntu-advantage-desktop-daemon ubuntu-desktop ubuntu-desktop-minimal ubuntu-docs ubuntu-mono ubuntu-release-upgrader-gtk ubuntu-session unattended-upgrades update-manager
  update-notifier update-notifier-common usb-creator-common usb-creator-gtk whoopsie-preferences x11-apps x11-session-utils x11-utils x11-xkb-utils x11-xserver-utils
  xbitmaps xbrlapi xcvt xdg-dbus-proxy xdg-desktop-portal xdg-desktop-portal-gnome xdg-desktop-portal-gtk xdg-user-dirs-gtk xfonts-base xfonts-encodings xfonts-scalable
  xfonts-utils xinit xinput xml-core xorg xorg-docs-core xserver-common xserver-xephyr xserver-xorg xserver-xorg-core xserver-xorg-input-all xserver-xorg-input-libinput
  xserver-xorg-input-wacom xserver-xorg-legacy xserver-xorg-video-all xserver-xorg-video-amdgpu xserver-xorg-video-ati xserver-xorg-video-fbdev xserver-xorg-video-intel
  xserver-xorg-video-nouveau xserver-xorg-video-qxl xserver-xorg-video-radeon xserver-xorg-video-vesa xserver-xorg-video-vmware xwayland yaru-theme-gtk yelp yelp-xsl zenity
  zenity-common
The following NEW packages will be installed
  foomatic-filters
The following packages will be upgraded:
  printer-driver-foo2zjs printer-driver-foo2zjs-common python3-distupgrade ubuntu-release-upgrader-core
4 to upgrade, 1 to newly install, 720 to remove and 96 not to upgrade.
Need to get 964 kB of archives.
After this operation, 1,519 MB disk space will be freed.
Do you want to continue? [Y/n] 

您会注意到 GNOME、桌面应用程序和大量的库都列在其中。

我确实还安装了一些快照,因此:

for s in firefox snapd-desktop-integration gnome-3-38-2004 gtk-common-themes  snap-store; do sudo snap remove --purge $s; done

这会在我的系统上留下core20baresnap snapd,我可能需要它们来进行服务器 snap。YMMV。

重新启动,所有图形包都将消失。

相关内容