The scripts that are called when runlevel x
starts are in the directory '/etc/rcx
.d'. If you have a look in /etc/rc2.d, for example, you'll likely see a file (which will be a symlink) called S99xdm. The number might
vary (I use kdm); it just tells the system what order to run the scripts, so for our current purpose it doesn't matter.
As I mentioned before, it's just a symlink to a file in /etc/init.d, as are all the other files in /etc/rc2.d. When the system boots into runlevel 2 it reads these files and executes them; so very simply, by removing the symlink, the script that launches xdm won't be called and X won't be started.
# rm /etc/rc2.d/S99xdm