Pages

Modifying the run level in Ubuntu 10.04

If you are running ubuntu 10.04 and are looking for the file /etc/inittab, you most probably will not find it. That is because ubuntu has changed a little the files that are read during the system boot.
The runlevel is now set by the file /etc/init/rc-sysinit.conf.
The default Runlevel is set to "2" which is the normal graphical mode.
If you have used any previous versions of linux you would be used to Graphical level being the run level 5, but that is again changed in ubuntu.

If you want change this run level you can set it as follows


1. Open a terminal
2. Run the command "sudo gedit /etc/init/rc-sysinit.conf"

3. In the file that opens search for the line
 env DEFAULT_RUNLEVEL=
4. After "=" enter the new runlevel number you want  and save the file.
5. Let  say we want to boot into text mode every time, so put "3" after the "=" and save the file
6. Now to start in text mode we need to stop gdm from loading , open the file gdm.conf using
"sudo gedit /etc/init/gdm.conf
7. You will see the following set of lines


start on (filesystem
          and started dbus
          and (drm-device-added card0 PRIMARY_DEVICE_FOR_DISPLAY=1
               or stopped udevtrigger))
stop on runlevel [016]

Change it to
start on (filesystem
          and started dbus
          and (drm-device-added card0 PRIMARY_DEVICE_FOR_DISPLAY=1
               or stopped udevtrigger))
     and runlevel[!3] 
stop on runlevel [016]


and runlevel[!3]   was the new line added.

Save the edited file and restart, it should boot in text mode.

Another way of changing to text mode is to pass the argument "text" to the kernel while booting.
we can do this as follows

1. While the sytem boots hold the "shift" key so that the gurb menu gets displayed
2. Move to the line that has the kernel you boot, some thing like

Ubuntu, with Linux 2.6.32-28-generic

3. Press "e"
4. Move to the line that starts with "linux"
5. Press e again to edit and at the end of this line add the word "text" and press enter.
6. Press cntrl+x to boot the system in text mode.

You can also add a permanent option in your grub menu for the text mode which can be done as follows.
1. Open the file /boot/grub/grub.cfg  using "sudo gedit /boot/grub/grug.cfg"
2. Go to the section that starts with "BEGIN /etc/grub.d/10_linux"
3. Copy the menuentry of the kernel you want to boot in text mode.
4. Open the file /etc/grub.d/40_custom using "sudo gedit /etc/grub/40_custom"
5. Paste the entry copied from grub.cfg at the end of this file.
6. In menuentry add the string "text" at the end of the line that starts with "linux" and save the file
7. Run the command "sudo update-grub2"
8. Now restart the system and hold shift to see the grub menu.
9. You should see a new entry at the end, which if selected should boot into the text mode.


9 comments:

  1. I tried
    sudo env RUNLEVEL=3
    on Ubuntu 10.04 and reboot but still the os is booting in GUI (desktop) mode.

    Finally I have found a true solution at http://ubuntuforums.org/showthread.php?t=1480813

    ReplyDelete
  2. The same had been mentioned in this post too.
    The post asks you to change it in the file /etc/init/rc-sysinit.conf and not set it in the terminal.
    Will try to make the post more clear.

    ReplyDelete
  3. hey Learning_Tux can u explain in more details please. I am stuck at this
    using 10.04

    ReplyDelete
  4. hi have modified the post to give more description and hope that it helps. .

    ReplyDelete
  5. Hey tux think,

    Another option is to simply change the following line:

    stop on runlevel [016]

    to:

    stop on runlevel [0136]

    ReplyDelete
    Replies
    1. Hi Josh,

      Thanks for the update, yes that is also a way of entering the text mode .

      Delete
  6. Why cant telinit option be used to change runlevel?

    ReplyDelete
    Replies
    1. telinit also allows us to change runlevels. But being a command we can run it only after logging in and the change is not retained .
      In one of the methods above we can change the runlevel during boot itself, while in the another we can make the change permanent,

      Delete