Sunday, October 9, 2016

Run level

In Linux system, "Run level" provides necessary service (and don't provide unnecessary service) for each run level. For example, you can decide that GUI should be enabled for "run level 5" and also you can decide what service shouldn't be enable for run level 5.

Run level for Ubuntu Debian GNU/Linux
0: Halt
1: Single user mode
2: Multi user mode
3: Multi user mode
4: Multi user mode
5: Multi user mode
6: Re-start
S or s: Single user mode
Single user mode is a special mode which can be used by root users. Single user mode is used for special cases which normal users should not touch, like system maintenance, because normal users can't log in the single user mode.

To check the current run level, run level command is used.

# runlevel
N means Run level was not decided because it was just after system was started. After N, the run level became 2  and this is the current run level.

To change the run level, "init" command or "telinit" command is used. The following example changes the current run level to 1.

# init 1

While normal users are logged in, if you log in as a single user, those normal users become unable to do anything and get stuck. So normal users should be logged out before you log in as a single user. If you use "wall" command, you can send messages to certain user(s). "wall" displays the contents of file or, by default, its standard input, on the terminals of all currently logged in users.

$ wall << .
Hi guys. This system is going down to maintenance mode. Beware.
.