System Runlevels in Ubuntu

System Runlevels in Ubuntu


Linux has different runlevels. The traditional System V Runlevels define what tasks can be accomplished in the current state (or runlevel) of a Linux system. Different Linux distro uses different runlevels for different purposes. Linux run levels are numbered 0 through 6.

In this tutorial we are going to learn how to find what runlevel the current user is running and how to change runlevels using telinit command.

This is a step-by-step tutorial on learn how to find what runlevel the current user is running and how to change runlevels using telinit command. To follow this tutorial, you need to have the following requirements:

• A computer with Ubuntu operating system installed.
• Basic knowledge of Ubuntu terminal. With basic I mean, how to open a terminal on Ubuntu and how to execute commands.

First open the terminal of your Ubuntu operating system. You can open your terminal by pressing Control, Alt and T at the same time. You can also go to the Unity dashboard and search by the keyword “Terminal” and click on the terminal. Or you can right click on the Desktop and click on “Open Terminal”.

What runlevel am I running?

To find what runlevel the current user is running, the ‘runlevel’ command is used.

Type in the following command and press Enter to find out what runlevel you’re running:

runlevel

You should see something like the screenshot below.

screenshot

It means, we are running in runlevel 5.

What number means what?

Run level 0 – Run level 0 is the system halt condition. Nearly all modern X86 computers will power off automatically when run level 0 is reached.

Run level 1 – Run Level 1 is known as ‘single user’ mode. In run level 1, no daemons (services) are started.

Run level 2 through 5 – Run levels 2 through 5 are full multi-user mode on Ubuntu. Run level 5 is used for graphical desktop environment and runlevel 3 is for text mode operation.

Run level 6 – Run level 6 is used to signal system reboot. This is just like run level 0 except a reboot is issued at the end of the sequence instead of a power off.

Change runlevel manually:

To change runlevel of your Ubuntu system, you can use the ‘telinit’ command.

Let’s see how that works.

I’ve already said, run level 0 shuts down your system. Lets see it changing current runlevel to 0 really shuts down our Ubuntu system.

Type in the following command,

telinit 0

It should shutdown your system.

Now let’s go to the single user mode, which is runlevel 1.

Type in the following command,

sudo telinit 1

sudo-telinit-1

Now type in your root password and press Enter.

press-enter

Now you’re logged in.

Let’s verify our runlevel using ‘runlevel’ command.

runlevel

You can see that, it’s 1.

That’s how telinit command can be used to change runlevels on Ubuntu.