sudo systemctl rebootis the modern command.sudo rebootandsudo shutdown -r nowdo the same thing on any current distribution.- Schedule one with
sudo shutdown -r +10 'message'and cancel it withsudo shutdown -c. - Check
/var/run/reboot-requiredfirst: it tells you whether a kernel or library update actually needs a reboot. - Confirm every service is set to start at boot before you restart, or the server comes back without your site on it.
- Never use
reboot -f: it skips the shutdown sequence entirely and is the quickest way to corrupt a database.
What is the command to reboot a Linux server?
Use sudo systemctl reboot. It asks systemd (the program that starts and stops services) to stop every service cleanly, unmount the disks and restart. On any recent distribution, sudo reboot and sudo shutdown -r now do exactly the same thing, so use whichever you remember.
# The modern form, and the one to prefer
sudo systemctl reboot
# Short form: identical behaviour on systemd distributions
sudo reboot
# The traditional form, still supported everywhere
sudo shutdown -r now| Command | What it does |
|---|---|
| systemctl reboot | Clean restart: stops services, unmounts, restarts |
| systemctl poweroff | Clean shutdown, machine stays off |
| shutdown -r +10 | Restart in ten minutes, warns logged-in users |
| shutdown -c | Cancel a scheduled shutdown or restart |
| systemctl suspend | Sleep. Almost never what you want on a server |
Day to day, you need only the first and the fourth.
Never use reboot -f
The force flag skips the shutdown sequence completely. No service gets to save what it holds in memory, and no disk is unmounted. It is the same as pulling the power cable, and it is how MySQL tables get corrupted. Keep it for a machine that responds to nothing else.
How do I schedule a reboot for later?
Use shutdown with a time. It warns anyone logged in, blocks new logins in the last five minutes, and can be cancelled right up until it runs. That last point is why it beats a cron job.
# In 10 minutes, with a message to logged-in users
sudo shutdown -r +10 'Kernel update, back in about 2 minutes'
# At a specific time, 24-hour clock, server local time
sudo shutdown -r 02:30 'Scheduled maintenance window'
# Change your mind
sudo shutdown -c
# Check whether one is already scheduled
systemctl list-jobs | grep -i shutdowntimedatectl first if the server might be on UTC while you are not.If you are connected over SSH, run the reboot inside tmux or screen. If the connection drops mid-command, you can still see the output when you reconnect, instead of wondering whether it ran.
Do I actually need to reboot?
Usually not. Most updates take effect as soon as the service restarts, and restarting one service beats restarting the whole machine. You need a reboot for a kernel update (the core of the operating system), a glibc update, or a firmware change. Debian and Ubuntu tell you directly.
# Debian / Ubuntu: this file exists only if a reboot is needed
ls -l /var/run/reboot-required 2>/dev/null && cat /var/run/reboot-required.pkgs
# RHEL family: needs-restarting is in the dnf-utils package
sudo needs-restarting -r
# Which services are running against deleted libraries?
sudo needs-restarting -s # RHEL family
sudo checkrestart # Debian / Ubuntu, from debian-goodiesneeds-restarting -r exits 0 if no reboot is needed and 1 if one is, so it works in a script.If a service is only holding an old library, restart that service instead. It takes seconds, not minutes, and nothing else on the machine notices.
sudo systemctl restart nginx
sudo systemctl restart php8.3-fpm
sudo systemctl restart mariadb
# Reload rather than restart where the service supports it:
# rereads config with no dropped connections
sudo systemctl reload nginxreload and restart differ. Nginx reloads without dropping a request; PHP-FPM needs a restart for most changes.What should I check before rebooting a production server?
The risk is rarely the reboot itself. It is finding out, two minutes later, that something only ran because someone started it by hand months ago and never set it to start at boot. Run these five checks first.
- 1Confirm every service you depend on starts at boot.
systemctl list-unit-files --state=enabledlists what will start. If nginx, php-fpm or your database is missing, fix it before you restart. - 2Check nothing long-running is in progress. A backup, a database import or a large rsync will be killed mid-write.
ps aux | grep -E 'rsync|mysqldump|tar'takes two seconds. - 3Take a backup you have tested. A reboot can expose problems that were already there, such as a disk that will not mount cleanly. Have a way back. Our backup strategy guide covers what makes a backup usable.
- 4Know how you get in if SSH does not come back. Console access through your provider's panel, or a second way in. Without one, a failed boot means a support ticket and an unknown wait.
- 5Pick a quiet time. Check your traffic rather than guessing. Overnight for you is daytime somewhere else if you have visitors abroad.
# Will everything come back on its own?
systemctl list-unit-files --state=enabled | grep -E 'nginx|apache|php|maria|mysql|postgres'
# Anything long-running I would be killing?
ps aux | grep -E '[r]sync|[m]ysqldump|[t]ar|[a]pt|[d]nf'
# Any failed units already? Fix these first, a reboot will not help
systemctl --failed
# How long has it been up, and what is the load?
uptimesystemctl --failed before a reboot, so you do not blame the restart for a problem that was already there.How do I confirm the server came back correctly?
Do not stop at a working SSH login. The machine being up and the site being up are different things. Check the boot, then the services, then the site.
# Confirm it really did restart, and when
uptime -s
who -b
# Did anything fail to start?
systemctl --failed
# How long did the boot take, and what was slow?
systemd-analyze
systemd-analyze blame | head -10
# Read this boot's log for errors only
sudo journalctl -b -p err
# Finally, test the site from outside the server
curl -s -o /dev/null -w '%{http_code} in %{time_total}s\n' https://example.com/journalctl -b shows only the current boot, which is what you want after a restart.The check that matters is from outside
A running service is not the same as a site that answers. The last command above tests the whole path: DNS, the network, the proxy and the application. On G7Cloud, uptime monitoring checks every site this way once a minute.
If something failed to start, the log says why. Linux system logs and where to find them covers reading journalctl and the logs each service keeps.
What do I do if the server will not come back?
Give it longer than you think. A machine checking a large disk (fsck) or waiting for a network drive can take several minutes with no outside sign of life. If it is still silent after ten, work through this list in order.
- 1Ping it. If it answers ping but refuses SSH, the machine booted and the problem is the SSH service or a firewall rule. That is a much better position to be in.
- 2Open the provider's console. The console shows the boot messages directly. A failed mount or a kernel panic (a crash at the core of the system) will be visible there.
- 3Look for a disk check. Checking a large disk can take a long time, and the console will say so. Wait for it.
- 4Boot the previous kernel. If the reboot followed a kernel update, pick the older entry in the GRUB boot menu from the console. If it boots, you have your answer.
- 5Boot into rescue mode to repair a bad /etc/fstab entry (the file that lists disks to mount at boot) or a broken mount. This is the most common cause of a machine that hangs during boot.
An untested fstab entry is the classic cause
A new mount in /etc/fstab with a typo stops the boot dead, and you will not find out until the next restart, perhaps months later. After editing fstab, always run sudo mount -a and check it returns cleanly before you reboot.
Frequently asked questions
What is the difference between reboot, shutdown -r and systemctl reboot?
On any current systemd distribution, none. systemd handles reboot and shutdown -r now, and both run the same clean shutdown as systemctl reboot. Only the shutdown form also takes a delay and a message to logged-in users.
How do I cancel a scheduled reboot on Linux?
Run sudo shutdown -c. It cancels any pending shutdown or restart and tells logged-in users. This only works for reboots scheduled with shutdown; one scheduled through cron or a systemd timer has to be removed there.
How do I know whether my Linux server needs a reboot?
On Debian and Ubuntu, check whether /var/run/reboot-required exists; the .pkgs file next to it lists the packages that asked for it. On AlmaLinux, Rocky and RHEL, run sudo needs-restarting -r, which exits 0 when no reboot is needed.
Will rebooting my server fix high CPU or memory usage?
It clears the symptom, not the cause, and the problem comes back. A reboot is fine for recovering a stuck machine, but find what was using the resource first. Our guide to troubleshooting high CPU and memory on WordPress walks through it.
How long should a Linux server take to reboot?
Usually 30 to 90 seconds for a virtual machine and two to five minutes for physical hardware, which spends most of that time in firmware before Linux starts. Run systemd-analyze afterwards for the exact split between firmware, kernel and the rest of the boot.
About G7Cloud Engineering
Articles written by the engineers who build and run G7Cloud: UK managed hosting and the AI Website Builder. We write about what we operate every day: containers, backups, databases, and the small-business websites that run on them.
More about G7Cloud →