The fastest way to reboot from command line

You can restart your computer from the command line in seconds using a single command. On Windows, type shutdown /r /t 0 and press Enter — the /r tells the system to restart, and /t 0 means restart when ready with no delay. On Mac or Linux, type sudo reboot and press Enter, then enter your password when prompted.

These commands work whether you're at the desktop or connected remotely to another machine. They're faster than clicking through menus, and they're useful when your mouse isn't responding, when you're working on a server, or when you need to restart as part of a script or automated task.

Key Takeaways

  • Windows restart command is shutdown /r /t 0 — the /r flag restarts the system and /t 0 means no delay.
  • Mac and Linux use sudo reboot followed by your password to restart when ready.
  • Add a delay by changing the number after /t — for example, /t 60 waits 60 seconds before restarting.
  • You can cancel a Windows restart before it happens by typing shutdown /a in a new command window.
  • Remote connections and automated scripts both use the same commands as a local restart.

Windows restart commands and what each flag does

The Windows shutdown command has several flags you can combine. /r restarts the computer. /s shuts it down without restarting. /t sets the delay in seconds — shutdown /r /t 0 restarts now, while shutdown /r /t 120 waits two minutes. /c lets you add a message that appears on users' screens before the restart happens.

For example, shutdown /r /t 300 /c "System updates installing" restarts in five minutes and shows that message to anyone logged in. This gives people time to save their work. If you change your mind, open a new command window and type shutdown /a to cancel — but only if the restart hasn't started yet.

You need administrator rights to run shutdown commands. If you're not logged in as an administrator, right-click the command prompt or PowerShell window and choose "Run as administrator" before typing the command.

Mac and Linux restart from terminal

On Mac, open Terminal (find it in Applications > Utilities or search for "Terminal"). Type sudo reboot and press Enter. The system will ask for your password — type it and press Enter again. The restart happens when ready.

Linux uses the same command: sudo reboot. On some Linux systems, you may also see sudo shutdown -r now work the same way — the -r flag means restart and "now" means do it when ready. Both commands require you to have sudo access, which most personal computers do by default.

If you want a delay before restart on Mac or Linux, use sudo shutdown -r +5 to restart in five minutes, or sudo shutdown -r 14:30 to restart at a specific time (using 24-hour format).

When to use a delay instead of when ready restart

An when ready restart (/t 0 on Windows, or no delay on Mac/Linux) closes all open programs without saving. Use this only when you're certain nothing needs saving, or when you're restarting a server that's not actively being used.

For a personal computer where you or others might have unsaved work, add a delay. shutdown /r /t 300 gives five minutes of warning. The system displays a notification on Windows, and users can save their files. If someone is actively using the machine, they'll see the countdown and have time to prepare.

Restarting a remote computer over the network

You can restart another computer on your network using the same commands, as long as you have the right permissions. On Windows, use shutdown /r /m \\computername /t 0 — replace "computername" with the actual name of the machine you want to restart. You need administrator rights on that remote machine.

On Mac or Linux, you typically use SSH to connect to the remote machine first, then run the reboot command as if you were sitting at that computer. Type ssh username@ipaddress, enter your password, then type sudo reboot. This is common for restarting servers or headless machines (computers without a monitor).

Troubleshooting when the restart command doesn't work

If you type the command and nothing happens, the most common reason is missing administrator rights. On Windows, close the command window, right-click it, and select "Run as administrator." On Mac or Linux, make sure you typed sudo at the start — that's what gives you the permission to restart.

If you see an error message like "Access Denied," you don't have administrator rights on that account. Ask your IT department or system administrator for help, or log in with an account that has admin access.

On Windows, if the restart seems to be taking too long, check whether a delay is set. Open a new command window and type shutdown /a to cancel the pending restart, then try again with /t 0 for an when ready restart.

Using restart commands in scripts and automation

Command-line restart is useful in batch files, PowerShell scripts, and scheduled tasks. You might restart a computer at a specific time each week for maintenance, or restart it after installing updates. The commands work exactly the same way — shutdown /r /t 0 on Windows, sudo reboot on Mac/Linux.

In a batch file or script, you can add a delay before the restart command runs, so other tasks finish first. For example, a Windows batch file might run updates, then wait 30 seconds, then restart. This gives the update process time to complete before the system goes down.

Frequently Asked Questions

Can I restart my computer from command line if I forgot my password?

No — you need to be logged in to open command prompt or terminal, and you need administrator rights to run the restart command. If you've forgotten your password, you'll need to reset it through your operating system's password recovery process before you can restart from the command line.

What's the difference between shutdown and reboot?

Shutdown turns the computer off completely. Reboot (or restart) turns it off and then back on automatically. On Windows, shutdown /s shuts down, while shutdown /r restarts. On Mac/Linux, sudo shutdown -h now shuts down, while sudo reboot restarts.

Will a command-line restart save my files?

No — the restart happens regardless of unsaved work. Always save your files before running a restart command, or use a delay flag like /t 300 to give yourself time to save. Programs will close without prompting you to save.

Can I restart just one program instead of the whole computer?

Yes, but you'd use a different command. On Windows, you can close a specific program with taskkill /im programname.exe, then restart it separately. On Mac/Linux, use killall programname. These don't restart the computer — they only close and restart individual applications.

What if the restart command is taking longer than expected?

Windows may be installing updates before restarting, which can take several minutes. On Mac/Linux, background processes may be shutting down. If it's been more than 10 minutes, you can force a restart by holding the power button for 10 seconds, but this risks data loss — only do this if the system is completely unresponsive.