Wednesday, May 29, 2024

 https://linuxstans.com/linux-restart-command

 

How to Restart Linux with a Command

In this tutorial, we’re going to show you how to use the restart command on Linux and how to restart (reboot) your system via the command-line interface (CLI).

We previously learned how to shut down Linux using a command. Now we’ll learn how to restart it. These commands will work on most Linux distros, including Ubuntu, Linux Mint, Fedora, Debian, Arch Linux, etc.

You might intuitively think that the command would be “sudo restart” but, it’s not.

How to restart Linux using the “reboot” command

First, open up Terminal (CTRL + ALT + T), or whatever else you’re using to access the CLI on your Linux distro.

The most simple way to do it is to use the “reboot” command, like so:

sudo reboot

This will restart your system. That’s the most simple and basic usage of the reboot command. For more advanced options, read below.

If you’re using a systemctl-based distro, you might need to use this command instead:

sudo systemctl reboot

How to force restart Linux with the reboot command

You can use the “-f” option with the reboot command to force restart your Linux system. By using the -f option, the system won’t sync and unmount filesystems.

sudo reboot -f

How to restart Linux with the shutdown command (with or without a delay)

Aside from shutting your system down, you can also reboot it with the “shutdown” command by using the -r option:

sudo shutdown -r now

This is useful if you want to restart your system after a given amount of time (instead of now), you can specify a delay. For example, if you want to reboot the system after 10 minutes, you can run:

sudo shutdown -r +10

And if you want to cancel an already scheduled reboot, you can run:

sudo shutdown -c

How to restart then halt Linux with a command

If you first want to restart your system and then halt it (stops all CPU functions) you can use the “-p” option:

sudo reboot -p

And that’s it! This was a pretty simple and straightforward tutorial. You can also restart Linux using the “init 6” command, but the reboot and shutdown commands are enough for most cases.

You can learn more about the commands we featured in our tutorial with:

man reboot
man shutdown

 

No comments:

Post a Comment