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
| Command | Effect | Notes |
|---|---|---|
| shutdown /r /t 0 | Restart now, no delay | Immediate local restart |
| shutdown /r /t 60 /c "Planned restart" | Restart in 60 seconds with a message | Message shown in user notifications |
| shutdown /r /f /t 0 | Restart now and force close apps | Use with caution to prevent data loss |
| shutdown /r /m \target_host | Restart a remote computer | Requires appropriate permissions |
Linux examples
| Command | Effect | Notes |
|---|---|---|
| systemctl reboot | Restart via systemd | Standard for most modern distributions |
| shutdown -r now | Immediate restart | Works without systemctl when available |
| shutdown -r +2 "Maintenance window" | Restart in 2 minutes with a broadcast message | Allows users to prepare |
| shutdown -r +5 -F | Delayed restart with filesystem check | -F may run fsck depending on configuration |
| shutdown -h now | Power off the system | Use 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.