Remove all trace of all desktop environments


When I setup my server - Ubuntu server 18.04 - four years ago, I was a newbie regarding linux server OSs. I installed several desktop environments (lightdm, gdm). The gdm proved unstable so I installed the xfce/xubuntu DEs.

I recently upgraded the server to the Ubuntu 20.04 server and would like to switch the DE to Cinnamon (from Linux Mint). I have tried to remove/purge all the DEs I don’t want. However, there seem to be leftover files and settings that prevent the cinnamon DE from starting.

I am also unable to have just the command prompt when the system boots.

Is there a way I can remove all traces of DEs so that I can get back to the command prompt of the server.

I’m stumped.

Any inputs will be much appreciated.



Hi Patrick,

Welcome to our forums.

To simply get the command prompt without any graphical session is fairly easy using systemd. To set the default boot target to command line, execute:

$ sudo systemctl set-default

To switch to the commandline session at once (not on next boot):

$ sudo systemctl isolate

Cleaning up old desktop leftovers are not that easy. At a package level, you could check a base install’s package list, compare to the packages you have on this server, and remove what isn’t needed. A simple thing like $ sudo apt remove gdm3 would remove the Gnome desktop, but will not remove your settings, which I take is a problem at your setup. These settings are on a per user basis, so they are stored in your home directory (most likely in hidden directories), so If you start with an empty home directory (or leave only needed stuff like .ssh directory), you can get rid of the old personal desktop settings. Just don’t forget to make a backup beforehand.

Thanks Sandman. I’ll give this a try.


Hello Sandman:

I tried sudo systemctl isolate The system left the GUI but then hung, requiring me to restart the system.

I have not tried [quote=“sandmann, post:2, topic:6901”]
sudo systemctl set-default
[/quote] yet. What command would you recommend to restore the desktop?

Many thanks.


Hi Patrick,

To revert to the original setting (that is, GUI on startup), you can use the following command:

$ sudo systemctl set-default

But since you did not use the set-default, the graphical session should have started when you restarted the system (is that so?). Unless there is something else wrong.