How do you completely remove ubuntu-desktop along with all installed packages with it? I'm using Ubuntu 14.04 server on vps and used sudo apt-get install ubuntu-desktop to install.

5 Answers 5


Even better than just doing remove, you can use purge and then autoremove.

sudo apt-get purge ubuntu-desktop
sudo apt-get autoremove

Purge option according to the man page for apt-get:

purge is identical to remove except that packages are
removed and purged (any configuration files are deleted too).

First do

apt-get remove ubuntu-desktop
apt-get autoremove

Then do the

sudo apt-get remove nautilus nautilus-* gnome-power-manager gnome-screensaver gnome-termina* gnome-pane* gnome-applet* gnome-bluetooth gnome-desktop* gnome-sessio* gnome-user* gnome-shell-common zeitgeist-core libzeitgeist* gnome-control-center gnome-screenshot && sudo apt-get autoremove

to end up with a completely GUI'less environment. This worked for me to remove the ubuntu-desktop I had installed on my Ubuntu Server


Remove the package and the auto-remove the installed dependencies. As root:

apt-get remove ubuntu-desktop
apt-get autoremove

See also apt-get(8) manual page for the autoremove argument.

autoremove (and the auto-remove alias since 1.1)

autoremove is used to remove packages that were automatically installed to satisfy dependencies for other packages and are now no longer needed.

sudo apt-get -y purge x11*
sudo apt-get autoremove -y && sudo apt-get autoclean -y

This will make sure that any gui based application will also be deleted (web browsers etc)


Little script of mine:

sudo apt-get install sed -y

#potrzebne jest dodatkowe utworzenie dwóch plików:
#usun.txt - gdzie po spacjach wpisujemy paczki do usunięcia - skrypt sam zajmie się usunięciem zależności
#instaluj.txt - gdzie po spacjach wpisujemy paczki do zainstalowania (obligatoryjny jeżeli po reboocie nie chcemy zastać czarnego, zimnego tty ;p)

#aptitude sam rozwiązuje zależności między usuwanymi a instalowanymi paczkami
#nie odpowiadam za ew. szkody ;p
#nie ma za co ;)

usun=`cat usun.txt`
chuj=`apt-cache depends $usun | sed -e 's/.*\ //g' | tr '\r\n' ' '`
instaluj=`cat instaluj.txt`
for i in $instaluj
inst=$inst"$i+ "
sudo apt-get install aptitude -y
sudo aptitude remove $usun $chuj $inst -y && sudo apt-get autoremove -y && sudo reboot

You have to make 2 additional files:

  1. usun.txt - that should contain metas (like ubuntu-desktop) separated with spaces you want dependencies to get rid of.

  2. instaluj.txt - metas you want to install/keep installed. That would be obligatory if you don't want to see deep, black tty after reboot. Otherwise I'm not responsible for damages.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.