I am running Ubuntu Server, and just installed the gnome desktop on there (I neeeded to run an application that would only work in a graphical interface). However, now the server boots to the GUI every time. I need the server to boot to the command line (runlevel 3). According to several articles that I've read, Ubuntu does not use the standard runlevels. What file do I need to modify in order to boot to runlevel 3 (or whatever the Ubuntu equivalent is)?
Theoretically, if Ubuntu were compliant with UNIX and Linux standard, adding '3' to grub's 'kernel' command in /boot/grub/menu.lst should have been sufficient, because runlevel '3' means no 'X11' according to this standard.
Unfortunately, Ubuntu has ignored the standard and that's why you'll need to change /etc/init/lightdm.conf or /etc/init/gdm.conf (or whatever DM you use) as well. This is how mine "on start" condition looks like:
In Grub's menu.lst I've also added a menu item that allows me to boot to runlevel 3:
Now I can chose between booting to runlevel 5 with X11 or to runlevel 3 without it.
I think there is a good answer here (askubuntu.com)
Just to answer your question on how tho change runlevel. Edit the file /etc/init/rc-sysinit.conf and change this line.
But changing runlevel won't stop X. Look at the start condition for ligthdm:
You need change the start condition in the /etc/init/XXX file to something than isn't met, e.g. a higher runlevel than you use. XXX is the display manager you use, e.g. lightdm.conf, gdm.conf, failsafe-x.conf.
Here is deep instrtuction for runlevels - http://sysadmin.te.ua/linux/linux-boot.html
The following is for Ubuntu Server 12 LTS
First you need open a real term with
Stop gdm with.
Remove gdm you dont need it at all on a server.
Set next boot runlevel with.
Without gdm you will need to install xinit if you want to still be able to run gui based apps without the gdm window manager.
Reboot to runlevel 3.
To run a GUI or desktop after reboot do.
This will start your gnome session as normal.
When finished simply logout of your desktop to and drop you back to a level 3 term
Also you can now start individual apps without a desktop too like.
or privileged with