For a Q&D solution, boot off a CD (knoppix, Redhat, Debian(?)) that gives you a shell or rescue mode, mount the system disks then remove gdm from the startups. On RH xdm is started up by init in /etc/inittab. Debian might do something different.