Jared's techno blog

Tuesday, December 28, 2004

How to stop X from starting automatically?

> > I am wondering how to prevent X-windows from starting up when I boot my
> > server. I looked at the run levels and didn't see something obvious. The
>
> Doesnt changing runlevel from 5 to 3 do?

Depends on the distro. For example, Debain seems to like to run as 2,
whether you get automatic-X-Window or not.

If you have a system that doesn't have separate runlevels (e.g., 3 & 5)
for text or X, look to see if XDM, GDM, KDM or some other alternative,
is being started in (for example) your /etc/rc2.d/ directory.


I use KDE on my Debian box here at home (Gnome on my Debian box at work).

My runlevel is the default shipped with Debain:

kendrick@amiga:~$ /sbin/runlevel
N 2


KDM, the KDE Display Manager (the login thing you get when X first comes
up, when it comes up automagically) is started by a script inside
/etc/rc2.d/ ... "S99kdm"

(S for Start, 99 for "do this as one of the last things)


That is, in fact, a symbolic link to "../init.d/kdm" (aka /etc/init.d/kdm),
which is the actual shell script which invokes the KDM process itself
(which happens to be the binary "/usr/bin/kdm").

Whew! Confused yet!?


Anyway - to disable KDM on my box, I would do:

$ su - [ switch to root ]
Password: [ enter root password, of course ]

# cd /etc/rc2.d/ [ go into runlevel 2's directory ]
# rm S99kdm [ remove KDM from the startup ]

-- or --

# mv S99kdm not.S99kdm [ simply rename it 'out of the way' ]


Note that deleting it ("rm") is perfectly safe, since it's a symbolic link:

$ ls -l /etc/rc2.d/S99kdm
lrwxrwxrwx 1 root 13 Dec 12 2001 /etc/rc2.d/S99kdm -> ../init.d/kdm



To get it back, you simply make a new symbolic link:

# cd /etc/rc2.d/
# ln -s ../init.d/kdm S99kdm [ make a link to "kdm" in the 'init.d' dir.,
and call it, in this directory, "S99kdm" ]


Now, I haven't really ever disabled/reenabled KDM (or GDM, at work) on my
Debian boxes, so I'm not sure if, after making the change, doing a
"telinit" (e.g., "/sbin/telinit 2") would actually DO anything,
since we're already in that runlevel.


You can, however, use the script (either the real one, in "/etc/init.d/",
or the symlink in "/etc/rc2.d/") to start and stop the service:

# /etc/init.d/kdm stop

-- and --

# /etc/init.d/kdm start

0 Comments:

Post a Comment

<< Home