Background
From time to time I inherit a server (or vm) that was set up as a server yet has a UI installed. The following code will remove xorg, display managers, etc. and leave you with a more clean/trim server.
Details
apt-get remove --purge xorg*
apt-get remove --purge nautilus*
apt-get remove --purge desktop-base
apt-get remove --purge python-gnome*
apt-get remove --purge gdm3
apt-get remove --purge x11-*
apt-get remove --purge gnome-*
apt-get autoremove --purge
Notes
- be careful / pay attention to the last step (
autoremove --purge
); check what will be remove to ensure you will not remove something unexpected/undesired.