creating a CLI session

Sam Noble sam at
Wed Dec 27 04:11:20 GMT 2006

On Tue, 2006-12-19 at 23:56 -0700, Ryan wrote:
> How would I make it so I can choose between GUI or no GUI when the 
> computer starts up? Is this easy to do? 

Runlevels are pretty good for this. In fact most non-debian families of
distros (sillily IMHO) base the entire concept of X vs CLI on runlevels.

Try this:

$sudo rm /etc/rc3.d/S*gdm

replace gdm with kdm for kubuntu. (or better yet cd into the rc3.d
directory and find the exact file name.)

Now X/gdm won't start in runlevel 3. ( I choose 3 since it makes sense
to RPM-based distro users who use 3 for CLI and 5 for X, [we children of
Debian use 2 for most everything but single user, reboot and shutdown.])

Now if you want to choose at startup you just need to pass the option to

By default Ubuntu hides the grub menu, so you'll have to press ESC at
the appropriate moment, or edit /boot/grub/menu.lst to not hide the
Once at the grub menu, you can either edit the appropriate line. (arrow
to it and press 'e') Or you can easily add an extra line in the menu.lst
file so that the option is always there.
Caveat Emptor, menu.lst has gotten confusing in the last few years
because it's now dual-purposed. It functions natively as the config file
for grub itself and also secondarily as the config for the update-grub
script that runs when you install a new .deb packaged kernel.
Update-grub gets it's config options from the lines that are commented
out with only one '#' hash. To actually comment the file you need to use
double-hashes '##'

For you, just find the stanza inside the "AUTOMAGIC KERNELS" section
that represents your normal startup:

title           Ubuntu, kernel 2.6.18-rc7-sam1
root            (hd0,4)
kernel          /boot/vmlinuz-2.6.18-rc7-sam1 root=/dev/hda5 ro vga=791 quiet resume2=swap:/dev/hda6

And add an identical section, but add a '3' to the end of the kernel
line, and edit the title however you please:

title           Ubuntu, kernel 2.6.18-rc7-sam1 CLI_only Session
root            (hd0,4)
kernel          /boot/vmlinuz-2.6.18-rc7-sam1 root=/dev/hda5 ro vga=791 quiet resume2=swap:/dev/hda6 3

A neat trick for you, assuming you don't often use the single user entry
that update-grub creates (and that you're comfortable enough with the
above outlined hand editing if you ever do need to use single user
mode.) Would be to use the 'alternatives' option as a way to auto
generate your "CLI session" login choice. You only need to edit a few
lines in /boot/grub/menu.lst, mine is pretty hacked up so forgive me if
I'm telling you to edit things that already match a default setup:

##hiddenmenu  <--you can delete this line or add the second hash to comment it out.

# alternative=true	<-- this is probably already set.

# defoptions=quiet resume2=swap:/dev/hda6  <-- don't change this just check what's there. (It won't be like mine unless you're using suspend2 in the same silly way that I am :)

# altoptions=(CLI_Session) quiet resume2=swap:/dev/hda6 3   <-- now edit this line to look just like your defoptions line but with our magic '3' at the end, the title adjustment immediately following the equals sign.

I think the Parentheses there are important.

Now just run update-grub:

$ sudo update-grub

And you should have your options available at boot, they'll look like
tihs in menu.lst:

title           Ubuntu, kernel 2.6.18-rc7-sam1
root            (hd0,4)
kernel          /boot/vmlinuz-2.6.18-rc7-sam1 root=/dev/hda6 ro vga=791 quiet resume2=swap:/dev/hda6

title           Ubuntu, kernel 2.6.18-rc7-sam1 (CLI_Session)
root            (hd0,4)
kernel          /boot/vmlinuz-2.6.18-rc7-sam1 root=/dev/hda6 ro vga=791 quiet resume2=swap:/dev/hda6 3

And the "neat trick" part is that it'll continue to work after kernel
upgrades and such.



If all this is too much, be aware that:

$sudo /etc/init.d/gdm stop
will work just fine to shut down X (even from in a gnome-session.)
(just in case you don't know it, <ctrl>+<alt>+<F1> will get you to the
CLI login prompt when GDM is running, so you don't have to log in to
gnome just to shut it down.)

$sudo /etc/init.d/gdm start
will get you back to the login just as easily.

More information about the ubuntu-utah mailing list