systems

How to Restart a Computer from the Command Line

Restarting a computer from the command line is useful when you work remotely, manage servers, or need a precise, repeatable restart sequence. Command-line restarts are faster to...

Mara Ellison
How to Restart a Computer from the Command Line

Why restart from the command line

Restarting a computer from the command line is useful when you work remotely, manage servers, or need a precise, repeatable restart sequence. Command-line restarts are faster to script, work over SSH, and avoid GUI dependencies. This guide covers standard, verified commands for Windows and Linux, explains flags that affect behavior, and outlines safety practices so you can run restarts with confidence.

Supported operating systems and intent

The primary ways to restart are the shutdown command on Windows and systemctl or shutdown on Linux distributions that use systemd. These tools are included with the operating system and designed for safe shutdown and restart cycles. Commands should be run with appropriate privileges, typically from an elevated or sudo-level session to avoid ‘access denied’ errors.

Windows restart syntax essentials

On Windows, shutdown /r is the standard restart switch. Adding /t sets a delay in seconds before the restart begins, and /f forces running applications to close. A typical command is shutdown /r /t 0, which starts the restart immediately. You can target a local or remote machine by appending a hostname or specifying credentials when necessary. Local policies and signed scripts may require elevation to execute these actions without error.

Linux restart syntax essentials

On systemd-based Linux, systemctl reboot triggers a clean restart by stopping userspace services and handing control to the kernel. If systemctl is unavailable, shutdown -r now schedules an immediate restart, and shutdown -r +m specifies a delayed restart in minutes. Forceful scenarios that skip graceful shutdown are handled with shutdown -r +m -F or by using systemctl with additional options. Non-systemd systems may rely on the shutdown command directly, so verify availability with which shutdown or checking init configuration.

Command reference and practical examples

Below are common, verified patterns you can run in a command shell. Replace target_host with a remote machine name when using administrative options, and ensure you have permission and saved work before issuing a restart.

Windows examples

CommandEffectNotes
shutdown /r /t 0Restart now, no delayImmediate local restart
shutdown /r /t 60 /c "Planned restart"Restart in 60 seconds with a messageMessage shown in user notifications
shutdown /r /f /t 0Restart now and force close appsUse with caution to prevent data loss
shutdown /r /m \target_hostRestart a remote computerRequires appropriate permissions

Linux examples

CommandEffectNotes
systemctl rebootRestart via systemdStandard for most modern distributions
shutdown -r nowImmediate restartWorks without systemctl when available
shutdown -r +2 "Maintenance window"Restart in 2 minutes with a broadcast messageAllows users to prepare
shutdown -r +5 -FDelayed restart with filesystem check-F may run fsck depending on configuration
shutdown -h nowPower off the systemUse when a full halt is intended

Timing, force flags, and user impact

The /t (Windows) and -t (Linux) options let you schedule restarts, giving users time to save work. A delay of 30–120 seconds is common in production environments to reduce disruption. Force flags such as /f or -F close applications or trigger filesystem checks, which can result in lost unsaved data. Use them only when necessary and when you understand the potential consequences on data integrity.

Safety and operational best practices

Always notify users before scheduled restarts and document the reason in change records or ticketing systems. For critical infrastructure, prefer maintenance windows and monitoring alerts that confirm services recover after restart. On remote machines, verify network access and account permissions beforehand, and keep a secondary management channel open, such as a separate SSH session or console access, in case the restart requires intervention.

Use cases and automation considerations

Command-line restarts are common in deployment pipelines, configuration management tools, and post-patch update workflows. Scripts should include error handling, confirmation steps, and logging to capture exit codes and timestamps. Where possible, schedule restarts during low-traffic periods and coordinate with stakeholders to minimize impact. Robust automation logs each restart attempt and outcome to support audits and incident review.

Related Reading

More pages in this topic cluster.

Essential Basic Shell Commands Reference

Mastering basic shell commands is foundational for efficient, reliable work on Unix-like systems. This reference covers navigation, file manipulation, permissions, processes, pi...

Read next
How to Create Files From the Linux Command Line

Creating files from the Linux command line is a foundational skill that supports scripting, automation, and efficient system administration. Whether you are building configurati...

Read next
How to Set a Restore Point

At its simplest, a restore point is a timestamped snapshot of your system files, registry, and installed programs that Windows can use to return your computer to a previous stab...

Read next