I have installed Debian Wheezy on an old laptop I want to use as a server. However, sometimes I want to use that computer to read webpages and write some code on it. So I want to have a GUI where I can install a web browser. I want to have either KDE or GNOME on it.

Is it possible to install a GUI that you can start with a command and stop again? The reason why I want this is to save resources when the server is only used as a server. It's an old laptop and doesn't have very much power.


The reason that X starts automatically is because the display manager is configured to do so. After installing gnome or KDE, disable the automatic start:

  update-rc.d -f kdm remove
  update-rc.d kdm stop 20 2 3 4 5 .

Replace kdm with gdm3 if you are using gnome. In order to start the X server, you can either start the display manager or run startx as your user.

/etc/init.d/kdm start # as root
startx # as your user

In Debian, the default x-session-manager is used when you startx, so configuring a ~/.xinitrc is not required.

| improve this answer | |
  • This is a good answer, thanks! The "problem" with Linux coming from a Windows system is that everything is in commands that you have to find in docs. It's not just looking through all the available buttons and there you go. After working more and more with Linux servers this year, I see that it actually gives the user a lot more freedom and that maybe it's good to see everything with a Linux-perspective. I have a question. Why do you do update-rc.d kdm stop 20 2 3 4 5 .? Is the update-rc.d-command just a "shortcut" for /etc/init.d/kdm stop? And why do you have the numbers at the end? – Friend of Kim Dec 4 '13 at 21:48
  • No, it's not a shortcut for that. It configures what level a service will be stopped/started by default. This is an alternative to disabling the service (as per my answer) that means it will actually be stopped if running. – goldilocks Dec 4 '13 at 21:53
  • Okay. Do you have a link to an article explaining what these levels are? I'm pretty new to Linux, and have only been using it for simple NginX and Apache-servers... – Friend of Kim Dec 4 '13 at 21:57

Is it possible to install a GUI that you can start with a command and stop again?

Yes. What mostly gets in the way of that is the display manager (DM). On a desktop system, this is started at boot; it presents a graphical login, which appears again when you log out. Without a display manager running, you can start X from the console with startx and when you log out or kill the X server, you're back to console.

Technically, the DM probably doesn't use a lot of resources. If you aren't logged in, maybe 50-100 MB of RAM (mostly X, which it depends on), and no CPU since it isn't doing anything. But it is unnecessary.

There's two things you can do. You can uninstall the display manager -- for GNOME, GDM, for KDE, KDM -- although this maybe a hassle if it's regarded as a dependency. There's no real advantage to this either, since it won't be much in terms of disk space.

The other thing is to change the nature of your default runlevel. "Runlevel" is a SysV init concept, and this won't apply on systemd (e.g fedora) or upstart (e.g. ubuntu) systems.

Traditionally, runlevel 5 was the only one that involved a GUI on linux. This has diversified and I think debian by default now uses X in everything but 1, and you don't want to use 1. You want to use one of 3, 4, or 5. However, the first thing you could try is to edit /etc/inittab here:

# The default runlevel.

Change '5' to '3' and try a reboot. If you still boot to GUI, then you need to remove the DM service from runlevel 3.

To do that, you have to figure out the name of the service. Look in /etc/rc3.d; one of the links in there will be xdm or gdm or kdm with a prefix like S03. If it's S03xdm:

update-rc.d xdm disable 2 3 4

This leaves runlevel 5 as the only DM'd runlevel, and since your default is 3, you'll have a console boot.

You can change runlevels via telinit, which once everything is configured as above, will also allow you to start X (telinit 5). Going back the other way won't work as well unless you set the DM to stop on other levels as per jordanm's answer. But as mentioned at the beginning, you can start X on any runlevel with startx, which is the simplest method.

| improve this answer | |
  • Thank you for an extensive answer! I just have to say that this did not make much sense. I'll have to read up on most of the terms you are using here. I'm a student and have learned Linux myself as the need for a stable and quick web server arose. That's why I initially installed Debian without the Desktop GUI, to force myself to learn to use it properly. The problem is just that I need to be able to view websites on the server at times... – Friend of Kim Dec 4 '13 at 21:55
  • 1
    Understanding SysV init is important and useful. It's not used on most distros anymore, but it will help you to understand the newer init daemons, systemd and upstart, if/when you need to. init is the first process spawned by the kernel at boot (PID 1) on all unix style OS's. It's then the parent of everything else, via services. SysV, systemd, upstart -- these are all "init systems" that do this in various ways. – goldilocks Dec 4 '13 at 21:59
  • Aha. So the services is a list of programs to initalize at a given level? Is it so that when starting the server it gets to level 2, then 3, then 4 and when the GUI is started level 5 is reached? So if xdm is enabled for level 4, it will run some code to take the system to level 5? Or is this wrong? Anyway what you do is to disable the GUI for everything except level 5, so that the GUI will only be there when manually initializing the GUI? So startx just takes the system to level 5? – Friend of Kim Dec 4 '13 at 22:07
  • This isn't really valid for the user's OS, Debian, which uses run level 2 by default (and the GUI starts in run level 2). This answer applies to RHEL, older versions of fedora, and possibly others. – jordanm Dec 4 '13 at 22:20
  • Kim > No, the system does not progress thru runlevels at boot, it goes straight to one level. The levels may be organized in terms of a progressive addition of services -- so there are more services at level 4 than 3. This is the way debian and redhat were originally. The debian systems I work on now are non standard and I did not consult a stock image when writing this, so as @jordanm points out I may have some particulars wrong. I stand behind it conceptually tho. Read man update-rc.d, man insserv, man startx startx -> does not change the runlevel... – goldilocks Dec 5 '13 at 11:22

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.