1

The runlevels 0 and 6 have the meaning of shutting down or rebooting the system.

If I enter the command init 0, the system will shut down as a result.

However my question is

  1. if the system is shutting down, because it has successfuly changed to runlevel 0
  2. or if I only triggered the change from my current runlevel to runlevel 0 (i.e. told my system that I want to go to runlevel 0) and it will reach it after shutdown? Which is of course never, as the system will do nothing after powered down.

In other words: Is the system in runlevel 0

  • while the system is shutting down (during the transition from running to being shut down), or
  • after the system has been shut down (as an unreachable runlevel that describes the result) ?

And an additional question regarding runlevel 6: Is the system in runlevel 6 during any phase of the next boot?

I am interested in the behaviour of Linux (if there is any difference to Unix).

1

init (whether you're using a classic SVR4 style init, systemd, runit, or something else) is coded as a state-machine. It only does things in response to events that cause it to change states. The transition from a system being powered on to being powered off is a change from whatever the current state is to the state defined by runlevel 0, and the shutdown for a reboot is the same, just changing to the state defined by runlevel 6 (and actually, the both transitions are pretty much identical except for that one final call into the kernel by init).

To answer your second question, the system is functionally 'in runlevel 6' during the period of time from when init calls into the kernel to reboot (which does not return) until the kernel hands off execution to `init during the next boot.

  • The implication of the whether you're using … systemd is that these systems have run levels too They do not. systemd does not have runlevels. Neither does runit-init, which maps just the numbers 0 and 6 onto native mechanisms; nor runsvchdir which manipulates named collections of service directory links. In fact, nothing apart from van Smoorenburg init and Nikola Vladov's ninit actually has runlevels. – JdeBP Apr 17 '18 at 18:18
  • @JdeBP No, systemd does support the concept of runlevels,it just doesn't call them runlevels, it calls them 'targets'. Functionally, they are identical, even though the naming is different. – Austin Hemmelgarn Apr 17 '18 at 20:55

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.