HOW TO CHANGE RUN LEVEL IN UBUNTU

Asked by Shridhar

Hi,

I am new to Ubuntu world, I heard that by default Ubunt boots in run level 2... but now i wanted to change it to runlevel 3 or 5....Please some suggest me how to change this..

Thanks, Shridhar

Question information

Language:
English Edit question
Status:
Answered
For:
Ubuntu Edit question
Assignee:
No assignee Edit question
Last query:
Last reply:
Revision history for this message
plutino (plutino) said :
#1

This is really tricky since ubuntu starts to use upstart. In the current start sequence, after all scripts in the S runlevel are processed, the system will execute /etc/init.d/rc-default to get into the next runlevel. With the /etc/init.d/rc-default shipped with Ubuntu, you don't really have any choice for anything other than runlevel 2 and single user mode. So in order to recorgonize the kernel runlevel parameter (a digit or letter S in the kernel parameter list), you will need to revise /etc/init.d/rc-default. Following is a simple implementation (I didn't test it because I don't have my ubuntu computer with me, but it should work)

# Before testing for single user runlevel in the kernel parameter list, add these lines:

RL=`sed -n -e "s/.*[ \t]\([S0-6]\)[ \t].*/\1/p" -e "s/.*[ \t]\([S0-6]\)$/\1/p" /proc/cmdline`

if [ 'x'$RL != 'x' ]; then
  telinit $RL;
elif ... (following the original script here to test "single" in the cmdline)

After this modification, you can add the runlevel parameter in grub to boot to the desired runlevel. You will probably want to change the /etc/rc*.d/ links for the runlevel you want, since by default, runlevel 2-5 are identical in Ubuntu.

Revision history for this message
plutino (plutino) said :
#2

Just want to add the following link in my blog:
http://plutino-cnotes.blogspot.com/2009/01/add-non-graphical-login-option-in.html
which details how to add an non-graphical boot option in Ubuntu

Revision history for this message
ubuntukungfu (keir-thomas) said :
#3

To switch runlevels easily, create an /etc/inittab file and add the line

id:3:initdefault:

Switch 3 to whatever run level you want.

Remember that Upstart emulates the old init system, including obeying an inittab file if one is present. I just tested and this works fine in 9.04 Alpha.

Can you help with this problem?

Provide an answer of your own, or ask Shridhar for more information if necessary.

To post a message you must log in.