Solved reboot system from terminal

Solved issue

CaffeineAddict

Well-Known Member
Joined
Jan 21, 2024
Messages
500
Reaction score
314
Credits
4,185
To reboot system from terminal the usual reboot command did it and still does it...
But on a systemd machine we can also do systemctl reboot or sudo systemctl reboot to reboot system.

Other than longer typing, is there a difference or preferred method?
 


systemd doesn't care if you just use reboot.
I typically do a "sync; reboot", just to make sure everything is done writing to disk before the reboot.

Amazingly enough, most distro's do not require you to sudo in order to reboot.
 
systemd doesn't care if you just use reboot.
I'd like to know what happens behind the scene?
I'm under impression that reboot is from old init system?

I typically do a "sync; reboot", just to make sure everything is done writing to disk before the reboot.
That's great advice, are you sure it's necessary?
 
That's great advice, are you sure it's necessary?

Not always necessary. I do it out of habit.
dd, scp, and web downloads happen in real time.
copying to and from USB stick's usually aren't, the blue progress bar will say it's done, but it really isn't.
If you try to "eject" the USB before it's done, it will say something like "wait" or "not ready".
If you do a "sync" first, then it will wait until all I/O is done before rebooting.
 
I'm under impression that reboot is from old init system?

I cannot say with certainty that it isn't but sysvinit used/uses init runlevels, more.

Because of retrospectivity for sysvinit recognition built into Debian and its descendants, you can use

Code:
init 6 # for rebooting, and

init 0 # that's a zero, for shutdown. Debian requires sudo before it.

I have been using them for 10 years, as a preference. I use reboot for Manjaro and other Arch-based distros.

You can read more here https://www.quora.com/What-is-the-difference-between-reboot-and-init-6-commands

There, according to Mohammed Tayeb Mohsin,

Both "#reboot" and "#init 6" commands are used to restart a Linux operating system, but they have some differences.

The "#reboot" command is a simpler way to restart the system. When you use this command, the operating system will immediately reboot, without any additional options. The "#reboot" command is usually used for quickly restarting a system.

The "#init 6" command is a more advanced way to restart the system. This command is part of the SysVinit system initialization program, which is responsible for starting and stopping services and processes on the Linux system. When you use the "#init 6" command, the SysVinit program will first execute a series of system shutdown scripts, then it will restart the system. The "#init 6" command is usually used when you need to shut down the system safely, close all running services and applications, and then restart the system.

In summary, the "#reboot" command is a simple and fast way to restart the system, while the "#init 6" command is a more advanced way to restart the system safely by executing shutdown scripts before rebooting.

HTH

Wiz
 
@wizardfromoz wrote:
There, according to ...
The man page for reboot has information that differs from the information in the quote in post #5.

In particular this extract from man reboot is informative about "poweroff, reboot and halt":
These commands are implemented in a way that preserves basic compatibility with the original SysV commands. systemctl(1) verbs poweroff, reboot, halt provide the same functionality with some additional features.

This suggests that reboot will close down gracefully, unmounting filesystems and syncing to flush buffers.

On the other hand, the reboot command using the --force option (or -f) has a different outcome as described on the same man page:
-f, --force
Force immediate power-off, halt, or reboot.
If specified, the command does not contact the init system.
In most cases, filesystems are not properly unmounted before shutdown. For example, the command reboot -f is mostly equivalent to systemctl reboot -ff, instead of systemctl reboot -f.

Watching the output on screen when rebooting with both commands, i.e. reboot, and later, reboot -f, as a machine had those commands run, there was considerably more output on the terminal screen when the reboot command was run, compared to the reboot -f command, the latter having to be run with root privileges. Catching a glimpse of that text on the screen running the reboot command, I could see "unmounting" activity, in accordance with the expectation from the manual page's description, whereas the considerably briefer output with the reboot -f command appeared to suggest that the kernel was running a lot less activity, which seems consistent with the expectation of a more sudden stop and restart of the system.

I've been unable to find a way of logging the reboot screen output, which is understandable since if it's unmounting filesystems, there's nothing to write to other than the standard output to the screen. A movie camera could record it all, but I haven't done that.
 
In particular this extract from man reboot is informative about "poweroff, reboot and halt":

This suggests that reboot will close down gracefully, unmounting filesystems and syncing to flush buffers.
Thanks, this is exactly what I suspected but forgot to read man page.
 

Members online


Top