23

We have installed Ubuntu desktop edition on our development server. Now that we have it in a data center we would like to strip it down to a server edition.

Is there an easy way of doing so rather than just going in and uninstalling packages by hand?

2
  • 2
    Re-installing is best: the server CD has kernel params set that the desktop is lacking (you can get them ofcourse with the desktop too but it is more work then a re-install ;))
    – Rinzwind
    May 5 '12 at 20:23
  • Also, one should remove x11 cruft too afterwards with sudo apt-get remove x11*
    – Rob K
    Jul 30 '12 at 10:53
15

It's possible to do it the other way around, but I've never seen anyone who was able to do this simply by installing a metapackage or something.

Your best bet is either:

  • a clean install
  • manually removing unneeded packages and installing the server components you need
1
  • 1
    A clean install is the way to go, but if you want to manually remove packages, run dpkg --get-selections "*" >~/applications.txt and delete what you know you don't need.
    – tinker
    Jul 29 '10 at 1:48
13

You can remove ubuntu-desktop and simultaneously auto-remove all its orphaned dependants:

sudo apt-get autoremove ubuntu-desktop

Add the --purge option if you also want to remove the configuration of the affected packages (and not keep it for possible later reinstallation).

If you have any other Desktop remove them as well. if you reboot after this you should have no GUI to log into. If you purge a program rather than just removing it you also remove any config files that may remain.

As Rinzwind suggests try sudo apt-get remove gnome-*.

Before Ubuntu 16.04 it also provides a special kernel package for server installations, linux-image-server:

  • sudo apt-get install linux-image-server and reboot.

Then I suggest you install the server applications you want, like ssh-server.


But as always it's better to make a clean install. It gives less risk of errors and broken packages.

9
  • 1
    Well I removed ubuntu-desktop, but it did nothing, since no packages depends on it. I then removed all the packages that ubuntu-desktop depends on, which works better, but it still leaves a bit of a mess with packages like unity-common, gedit-common, etc. May 5 '12 at 19:00
  • @BartvanHeukelom well, did you purge it or just remove it? edited the question.
    – Alvar
    May 5 '12 at 20:25
  • 1
    iirc sudo apt-get remove gnome-* would take care of most packages. Unity should be removed alongside this (cuz of dependencies). (needs confirmation though since I tend to not do this)
    – Rinzwind
    May 5 '12 at 20:27
  • I removed it (accidentally), didn't purge, but AFAIK that shouldn't matter regarding dependencies. May 7 '12 at 8:49
  • 2
    Since 12.04, there is no difference in kernel between Ubuntu Desktop and Ubuntu Server since linux-image-server is merged into linux-image-generic. (from Ubuntu ServerFaq) Jan 2 '14 at 12:37
12

Note: as stated in comments, tasksel should only be used to install tasks, not remove them. In this specific task (remove desktop -> install server) it seems to work fine. So use it with caution.


You can try tasksel. With it, you can do what you want by selecting Basic Ubuntu Server and unchecking Ubuntu desktop.

sudo apt-get install tasksel

tasksel screen

5
  • 1
    Can you or someone else confirm this works? You say try, but if it does work this is a great answer.
    – djeikyb
    May 29 '12 at 20:01
  • 1
    Excerpt from Ubuntu Tasksel page: WARNING: Use tasksel only to install tasks, never to remove any! According to launchpad.net/bugs/574287 it will remove each package in the list of that task (and possibly render your system unusable). May 29 '12 at 20:12
  • As per above, I don't recommend you to use tasksel in your case. May 29 '12 at 20:13
  • 1
    @djeikyb i tried this with ubuntu 9.10 and ubuntu 11.10, and both work (wubi install, remove desktop and installing "server packages"). In 11.10 there's a small glitch: the system boots but dont shows you the login prompt.
    – Salem
    May 30 '12 at 10:27
  • @AndrejsCainikovs i only used tasksel with this specific task (remove desktop -> install server) and in the systems i used it works. I will update the answer
    – Salem
    May 30 '12 at 10:40
2

If you want to just not run the DM and WM on startup but keep the ability to run them at will you can run:

sudo systemctl set-default runlevel3.target

then reboot.

The system will boot to runlevel 3 (init 3) which does not start the DM and WM and all the other stuff related to the desktop environment, but starts everything else. When the system boots into the tty1 terminal at the console, you can log in then

sudo init 5

to get to the desktop environment login.

On the ubuntu and xfce4 desktops I was testing with the GUI logout button hung my system.
On the ubuntu desktop, the power down and restart buttons worked fine; the xfce4 desktop only has a logout button.

The safe way to exit back to tty only is to open a terminal and run:

sudo init 3

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.