Sooner or later, you're going to have to reboot your Linux system. Whether you need to fix a problem or want to restart your system after installing updates, you can do it in the command line, just as with everything else in Linux.
With the reboot Command
The easiest way to reboot your Linux system is with the reboot command. To reboot the system immediately, just type:
sudo reboot
Your system will then reboot.
Using the shutdown Command
The reboot command is a front end for the shutdown command. Both of these commands have the same arguments. If you just want to reboot your machine using shutdown, use the -r flag:
sudo shutdown -r
The shutdown command takes other arguments, so you can customize how you want to reboot. By default, it will take time strings that let you reboot some time into the future.
The syntax for a time stream is "hh:mm", where "hh" is the hour and "mm" is the minute of the time you want to reboot in the 24-hour clock format.
For example, if you wanted to reboot your system at midnight, you'd issue this command:
sudo shutdown -r 00:00
There's also a shortcut for specifying minutes, "+n", where "n" stands for minutes. For example, to reboot in five minutes:
sudo shutdown -r +5
The second argument is a "wall message," which prints a message to every terminal connected to the system. On a shared system like a server, it's a good idea to give other active users a heads-up so they can save their work.
sudo shutdown -r +10 "System rebooting in 10 minutes!"
If you've changed your mind and want to cancel a reboot you've scheduled, type:
sudo shutdown -c
The reboot and shutdown commands work on both local and remote systems. If you're connected to a server over SSH, when you reboot, you will be disconnected unless you're connected to a serial console.
If something goes wrong with the system and you were logged in over SSH, you might only be able to log in again directly on a terminal connected to the system.
Most data centers offer serial console servers that connect to rack-mounted servers or otherwise offer "out-of-band' management that lets you access the system outside of SSH, often through a web interface. These features let you manage the system even as it reboots.
Now You Can Reboot Your Linux System
It's easy to reboot your system from the command line, now or in the future, with both the reboot and shutdown commands, even remotely. If you want to shut down your Linux computer, you can do that too from the command line.
0 Comments