When you are managing a Linux server in a data center halfway across the world, you do not have the luxury of pressing a physical power button. You must control everything through a remote SSH terminal connection.
If you have just installed a major kernel update, or if system services have crashed irreparably, you will need to reboot the server. Fortunately, Linux provides several commands to restart a system safely from the command line without causing data corruption.
Method 1: The Reboot Command (The Fastest Way)
The simplest and most direct way to restart a Linux machine is the reboot command. Because restarting a server will disconnect all users and terminate all running software, you must have root (administrator) privileges to run this command.
Open your terminal and type:
sudo reboot
The system will ask for your password. Once you press Enter, Linux will immediately begin gracefully shutting down all running services, unmounting the hard drives safely, and then it will trigger a hardware restart.
Method 2: The Shutdown Command (The Safest Way)
While reboot is fast, the shutdown command offers much more control, making it the preferred choice for enterprise server administrators.
To restart a server immediately, use the -r (restart) flag combined with the word now.
sudo shutdown -r now
The result is identical to the reboot command. However, the true power of shutdown is the ability to schedule the restart. If you have active users on the server, restarting it instantly will destroy their unsaved work. You can tell the server to wait 15 minutes before restarting by typing:
sudo shutdown -r +15
When you run this command, Linux will instantly broadcast a warning message to the terminal of every user currently logged into the server, telling them the system is going down in 15 minutes, giving them time to save their data.
How to Cancel a Scheduled Reboot
If you scheduled a reboot for 15 minutes from now, but you suddenly realize a critical database backup hasn’t finished running yet, you must cancel the restart.
To abort a pending shutdown or reboot, use the -c (cancel) flag.
sudo shutdown -c
Linux will cancel the timer and broadcast a new message to all users letting them know the reboot has been aborted and the server will remain online.