4

I'm very new to Linux, and I'm setting up a Debian server. Since I don't have any need for a GUI most of the time, I'd like to disable it from running at startup and wasting system resources.

However, I'd still like to have it available for running Firefox and performing tasks that might be painful to do with the command line.

I've tried doing some research on the subject, and people seem to say this line will do it:

#update-rc.d -f gdm remove

(I assume the hash signifies I should enter it into the terminal; if I leave it in there nothing happens)

If I SSH in as root and enter that line, I receive the result:

update-rc.d: using dependency based boot sequencing

which is wonderfully cryptic. When I reboot the computer afterwards, GNOME comes right back up. Does anyone know what I'm doing wrong here?

2

Depending on the debian version you are running it can be

update-rc.d -f gdm remove

or

update-rc.d -f gdm3 remove

Reboot.. Thats it! I just tested it

  • This might make it come back on a package upgrade. – derobert Jun 12 '13 at 16:33
1

Assuming system is a Red Hat variant (Debian directions are slightly different) - See U&L Question: How to boot Debian into text mode without using GUI?

Red Hat variants

Rather than remove gdm you might want to consider running the system in runlevel 3 rather than runlevel 5.

RunLevels

ID  Name                                Description
--  ----                                -----------
0   Halt                                Shuts down the system.
1   Single-user Mode                    Mode for administrative tasks.
2   Multi-user Mode                     Does not configure network interfaces
                                        and does not export networks services.

3   Multi-user Mode with Networking     Starts the system normally.
4   Not used/User-definable             For special purposes.
5   Start the system normally with      As runlevel 3 + display manager.
    appropriate display manager.
    ( with GUI )

6   Reboot                              Reboots the system.

You can see which runlevel a system is in using the command runlevel:

$ runlevel
N 5

This is showing you the previous and current runlevels. If there isn't a previous runlevel a N is substituted in that position.

To change your runlevel you can temporarily do it using the command telinit <runlevel>, for example:

telinit 3

Re-running runlevel now shows this:

$ runlevel
5 3

To make this change permanent you can edit the file /etc/inittab and change this line:

$ sudo vim /etc/inittab
id:3:initdefault:

Then do a reboot and your system should now be in runlevel 3.

chkconfig

To see if a serivce is configured for given runlevel you can use the command chkconfig:

chkconfig --list | grep ssh
sshd            0:off   1:off   2:on    3:on    4:on    5:on    6:off

So ssh is setup to start in runlevels 2,3,4, & 5.

Debian/Ubuntu variant

On Debian/Ubuntu the location of things is different and the runlevels are different too.

RunLevels

0 - shutdown
1 - single user mode
2 - multiuser graphical mode
6 - reboot

The default runlevel is 2. You can confirm this with the command runlevel:

$ runlevel
N 2

The runlevel can be changed with the telinit command:

telinit 3

To make these changes permanent you can edit the file: /etc/init/rc-sysinit.conf and change the following line:

$ sudo vim /etc/init/rc-sysinit.conf
env DEFAULT_RUNLEVEL=2

sysv-rc-conf

The tool sysv-rc-conf can be used from the terminal to interrogate what services are wired to run in a given runlevel. For example:

$ sysv-rc-conf --list|grep rsync
rsync        2:on   3:on    4:on    5:on

Some services aren't going to show up under this, however. Under Debian/Ubuntu the sysV services mechanism is slowly being phased out by a new mechanism called upstart.

$ status ssh
ssh start/running, process 928

You can see which runlevel the service will start in like so:

$ initctl show-config ssh
ssh
  start on (filesystem or runlevel [2345])
  stop on runlevel [!2345]
  • Thanks! Just to check, the SSL daemon will still auto-start, right? It'd be a problem if it turned out that GNOME was the one responsible for that, and disabling it also disabled my ability to control the machine. – Schilcote May 28 '13 at 1:54
  • Check to make sure it's configured to start in runlevel 3. I believe the command is chkconfig --list |grep ssh. You can manually check by looking in the /etc/rc3.d directory for a S##ssh type of link. The ## are numbers which correspond to the order in which ssh should be started when in that runlevel. The name might be slightly different, I'm not on a Debian system at the moment. – slm May 28 '13 at 1:58
  • Okay, problem: runlevel reports that the system is running at level 2 when I enter it into an SSH terminal or via the "root terminal" app locally. If I try to run it as the sever user, it says "command not found". "sudo runlevel" tells me I'm not a sudoer, even after I "adduser server sudo" (which I suspect is something one shouldn't do anyway). /etc/inittab states that level 2 is the default level. – Schilcote May 28 '13 at 2:08
  • This is debian, correct? I believe 2 is the normal runlevel. Hmm. Here's the equivalent command to chkconfig it's called sysv-rc-conf --list|grep ssh. Let me google a bit, brb. – slm May 28 '13 at 2:13
  • Here, Gilles provides the details for setting up a Debian system w/o GUI - How to boot Debian into text mode without using GUI? – slm May 28 '13 at 2:17
1

The graphical environment is started by an "X display manager". Depending on the version of Debian you're running, that's either gdm or gdm3 (at least for GNOME; there are other display managers such as kdm for KDE).

You can check which display manager is in use on your system by looking in /etc/X11/default-display-manager. You can change it by editing that file. You could disable it by changing that file to contain, say, none. But then you'd not be able to manually start it when needed (though startx would still work fine).

Alternatively, you can change gdm3 (or whichever) to not start on boot. You do this the same as any other service, by manipulating links in /etc/rc?.d. On a recent enough Debian, you can easily do this with update-rc.d gdm3 disable. You can then start it manually by running service gdm3 start.

0

On my Debian system the display manager was LightDM, so to remove it from the boot process I issued update-rc.d lightdm disable.

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.