Loading...
X

What is the difference between “systemctl reboot” and “reboot” and “systemctl poweroff” and “poweroff”

What's the difference between

sudo systemctl reboot

And

sudo reboot

Is it true that the use of commands depends on the operating system, and that one will execute a shorthand version, the other will use systemctl?

Answer:

The halt, poweroff, reboot commands are implemented to maintain basic compatibility with the original SysV commands. Verbs

  • systemctl halt
  • systemctl poweroff
  • systemctl reboot

provide the same functionality with some additional features.

That is, reboot is now also systemctl. You can verify this:

which reboot
/usr/sbin/reboot

file /usr/sbin/reboot
/usr/sbin/reboot: symbolic link to /bin/systemctl

That is, the reboot command is actually a symbolic link to systemctl.

In turn, the command

systemctl reboot

is an abbreviation for

systemctl start reboot.target --job-mode=replace-irreversibly --no-block

That is

reboot

this is exactly the same as

systemctl reboot

as well as

systemctl start reboot.target --job-mode=replace-irreversibly --no-block

This is true for distributions that have switched to systemd (for example, Arch Linux, the entire Debian family, including Ubuntu). That is, for most modern distributions, except for those on which SysV remained.

In some cases, the reboot command does not work – see Error “Failed to talk to init daemon” for details. In this case, to restart the computer, you must add the -f option:

reboot -f

The shutdown command is:

poweroff -f

Even if these commands did not help, then use the options with the double option -f.

To turn off your computer do:

poweroff -f -f

Or restart your computer with the command:

reboot -f -f

The -f option means forced immediate stop, shutdown, or reboot. When specified once, this results in an immediate but clean shutdown by the system manager. If specified twice, it results in an immediate shutdown without contacting the system manager.

When using the -f option with systemctl halt, systemctl poweroff, systemctl reboot, or systemctl kexec, the selected operation is performed without shutting down all units. However, all processes will be forcibly terminated, and all file systems will be unmounted or remounted read-only. Therefore, it is a radical, but relatively safe option to request an immediate restart. If you specify --force twice for these operations (except for kexec), they will be executed immediately, without killing any processes or unmounting any filesystems. Warning: specifying --force twice for any of these operations can result in data loss. Note that if you specify --force twice, the selected operation is performed by systemctl itself and is not associated with the system manager. This means that the command must be executed even if the system manager fails.


Leave Your Observation

Your email address will not be published. Required fields are marked *