In a SysVinit-compatible environment, show the previous and current runlevels as two fields.
Do not change system state.
Which command is appropriate?
runlevel displays the previous and current runlevel. If there is no previous value, it may show N.
Detailed explanation
telinitIncorrect. telinit requests a runlevel change.
Incorrect. telinit requests a runlevel change.
runlevelCorrect. runlevel prints the previous and current values.
Correct. runlevel prints the previous and current values.
initdefaultIncorrect. initdefault is an inittab action rather than a command.
Incorrect. initdefault is an inittab action rather than a command.
whoIncorrect. who lists logged-in users and does not report runlevels.
Incorrect. who lists logged-in users and does not report runlevels.
Try it yourself
An example you can run in a temporary verification environment.
runlevel 2>/dev/null || echo 'runlevel information is unavailable'Expected result
N 5等の2項目、または情報未提供の表示Key points
- runlevel is read-only
- The left field is previous
- The right field is current
Notes
- Environment: Linux / SysVinit互換コマンド
- Command output formatting can vary slightly by distribution or tool version.
- Run the example in a temporary directory or process when possible.
Foundation review
Read the scope first
Check whether the command acts on the current shell, a new process, an existing process, or a file.
Verify the observable result
Use the supplied command and compare the output with the expected result.