I just did my first install of any Linux OS, and I accidentally selected "Desktop GUI" in the install, but I want to build everything myself. Is there any way by which I can remove the GUI environment without re-installing OS?
4 Answers
Debian uses tasksel for installing software for a specific system. The command gives you some information:
> tasksel --list-tasks i desktop Graphical desktop environment u web-server Web server u print-server Print server u dns-server DNS server u file-server File server u mail-server Mail server u database-server SQL database u ssh-server SSH server u laptop Laptop u manual manual package selection The command above lists all tasks known to tasksel. The line desktop should print an i in front. If that is the case you can have a look at all packages which this task usually installs:
> tasksel --task-packages desktop twm eject openoffice.org xserver-xorg-video-all cups-client … On my system the command outputs 36 packages. You can uninstall them with the following command:
> apt-get purge $(tasksel --task-packages desktop) This takes the list of packages (output of tasksel) and feeds it into the purge command of apt-get. Now apt-get tells you what it wants to uninstall from the system. If you confirm it everything will be purged from your system.
- 3Hm, what do you make of this, with
tasksel --task-packages desktopI only gettask-desktop? But I have some of those packages (e.g., twm).Emanuel Berg– Emanuel Berg2012-11-21 22:55:16 +00:00Commented Nov 21, 2012 at 22:55 - 1What is the output of
tasksel --list-tasks | grep "^i"? Is the packagedesktop-baseinstalled?qbi– qbi2012-11-22 21:03:01 +00:00Commented Nov 22, 2012 at 21:03 - 1
tasksel --list-tasks | grep "^i"doesn't give my anything: I have onlyulines fortasksel --list-tasks, includingu desktop Debian desktop environment.aptitude show desktop-basesays that package (desktop-base) is installed, though. Are those related? I'm not sure what to make of this.Emanuel Berg– Emanuel Berg2012-11-22 22:21:30 +00:00Commented Nov 22, 2012 at 22:21 - 8This answer partially worked for me, but I also had to:
dpkg --get-selections(showed me that I hadxserverpackages installed),apt-get purge xserver-*(delete all the xserver packages).Daniel Bank– Daniel Bank2015-10-28 16:17:26 +00:00Commented Oct 28, 2015 at 16:17 - @qbi I am on mint, and
tasksel --list-tasksshows no option for desktop in my case i stands for LAMP serverPrvt_Yadav– Prvt_Yadav2018-05-06 03:59:18 +00:00Commented May 6, 2018 at 3:59
It means Debian changed the behaviour of this by now using a single "meta" package called task-desktop which pulls in the other packages via dependencies and recommends. So it's true what tasksel tells you, it just installs that single package, but if you look at the details of that, like so:
apt-cache show task-desktop you will see the other (actual) packages this pulls in in the lines starting "Depends:" and "Recommends:". To remove them try "apt-get remove task-desktop" or list the package names individually.
- 3You can just uninstall the task-desktop package and the do a
apt-get autoremoveto purge the dependencies.Thorian93– Thorian932019-10-07 08:20:11 +00:00Commented Oct 7, 2019 at 8:20 -
apt autoremove --purgeto purge also the dependent packagesrubo77– rubo772022-04-14 20:35:50 +00:00Commented Apr 14, 2022 at 20:35
apt purge task-desktop task-german task-german-desktop hyphen-en-us libglu1-mesa libreoffice-* libu2f-udev mythes-en-us x11-apps x11-session-utils xinit xorg xserver-* desktop-base totem gedit gedit-common gir1.2-* gnome-* gstreamer* sound-icons speech-dispatcher totem-common xserver-* xfonts-* xwayland gir1.2* gnome-* vlc* then
apt autoremove --purge to purge all dependent packages as well.
First, we need to issue the following command on the terminal :
sudo telinit 1 to get into rescue mode, from where we can clean up all the GUI packages, without any locking issues, easily and then :
apt purge task-desktop task-german task-german-desktop hyphen-en-us libglu1-mesa libreoffice-* libu2f-udev mythes-en-us x11-apps x11-session-utils xinit xorg xserver-* desktop-base totem gedit gedit-common gir1.2-* gnome-* gstreamer* sound-icons speech-dispatcher totem-common xserver-* xfonts-* xwayland gir1.2* gnome-* vlc* apt autoremove --purge Hope this helps someone.
dpkg --get-selectionsas per @daniel-bank's comment). If using the method of removing base packages, then autoremoving the rest, it's easy to lose desired packages that were installed as dependencies.apt-markcan set them as explicitly installed, preventing automatic removal, but the end result is never as clean as a fresh install would have been.