Welcome to a tutorial on how to restart a computer from the command prompt (or terminal if you are using Mac). Have an unresponsive user interface? Need to force restart a semi-conscious computer? Or writing a maintenance script to reset the computer? Long story short, to restart a computer from the command or terminal:
- Windows: Start-R > Type in “cmd” and “enter” > Type in “shutdown /r” in the command prompt.
- Mac: Command-Space > Type in “terminal” and “enter” > Type in “sudo reboot” in the terminal.
But there’s a little bit more to how we can play with these commands, and alternatives when the computer is totally not responding. Read on to find out!
TABLE OF CONTENTS
| Section A
| Section B
| Section C
WINDOWS RESTART & SHUTDOWN
The command to shut down or restart a Windows computer is “shutdown”. But over the many years, it has evolved to become more capable and complicated.
ALL THE SHUTDOWN OPTIONS
To get all the options, simply type
shutdown /? in the command prompt:
D:\>shutdown /? Usage: shutdown [/i | /l | /s | /sg | /r | /g | /a | /p | /h | /e | /o] [/hybrid] [/soft] [/fw] [/f] [/m \\computer][/t xxx][/d [p|u:]xx:yy [/c "comment"]] No args Display help. This is the same as typing /?. /? Display help. This is the same as not typing any options. /i Display the graphical user interface (GUI). This must be the first option. /l Log off. This cannot be used with /m or /d options. /s Shutdown the computer. /sg Shutdown the computer. On the next boot, restart any registered applications. /r Full shutdown and restart the computer. /g Full shutdown and restart the computer. After the system is rebooted, restart any registered applications. /a Abort a system shutdown. This can only be used during the time-out period. Combine with /fw to clear any pending boots to firmware. /p Turn off the local computer with no time-out or warning. Can be used with /d and /f options. /h Hibernate the local computer. Can be used with the /f option. /hybrid Performs a shutdown of the computer and prepares it for fast startup. Must be used with /s option. /fw Combine with a shutdown option to cause the next boot to go to the firmware user interface. /e Document the reason for an unexpected shutdown of a computer. /o Go to the advanced boot options menu and restart the computer. Must be used with /r option. /m \\computer Specify the target computer. /t xxx Set the time-out period before shutdown to xxx seconds. The valid range is 0-315360000 (10 years), with a default of 30. If the timeout period is greater than 0, the /f parameter is implied. /c "comment" Comment on the reason for the restart or shutdown. Maximum of 512 characters allowed. /f Force running applications to close without forewarning users. The /f parameter is implied when a value greater than 0 is specified for the /t parameter. /d [p|u:]xx:yy Provide the reason for the restart or shutdown. p indicates that the restart or shutdown is planned. u indicates that the reason is user defined. If neither p nor u is specified the restart or shutdown is unplanned. xx is the major reason number (positive integer less than 256). yy is the minor reason number (positive integer less than 65536).
BASIC SHUTDOWN PROCEDURES
Most beginners will probably freak out immediately at how many options
shutdown has, but there are only 4 basic ones to take note of:
shutdown /sShuts down the computer.
shutdown /rRestarts the computer.
shutdown /lLog off.
Yep, that’s all to it.
FORCE SHUTDOWN A STUBBORN PC
If an application or process is blocking the shutdown or reset, we can use
shutdown /p /f to force a shutdown… No warnings will be given, and it will act immediately.
MAC RESTART & SHUTDOWN
There are 3 commands to shut down a Mac – shutdown, halt, and reboot. Of course, being a Unix based system, these commands will also work on Linux… Although things might somewhat vary depending on the Linux build.
THE SHUTDOWN SYNTAX
WS-iMac:~ wstoh$ sudo shutdown usage: shutdown [-] [-h [-u] [-n] | -r [-n] | -s | -k] time [warning-message ...]
Unlike Windows, the
shutdown command is very cryptic… Which is even scarier for beginners. But in short, the
sudo part is “run as administrator”, and it has a syntax of
shutdown [OPTIONS] [TIME] [MESSAGE].
shutdown -hHalt the system.
shutdown -rReboot the system.
shutdown -sPut the system into sleep mode.
shutdown -kMore for Mac server usage. Does not shut down, but kick everyone off the system.
The shutdown time is required, and there are generally 3 ways to define it:
shutdown -h nowRight now.
shutdown -h 12:34An exact time.
shutdown -h +15Specified minutes later.
This is optional and will serve a warning message to all users who are logged on to the Mac before shutting down or resetting.
HOW ABOUT HALT AND REBOOT?
In the layman terms:
shutdown -his equals to calling
shutdown -ris equals to calling
But not really… It’s kind of confusing. But
reboot all belong to the same system module that deals with shutting down and rebooting.
That’s it for the shutdown commands, and here are a few extra bits that may be useful to you.
Hold your horses, before you force a reset or power down, there might still be hope.
- Windows – Press Ctrl-Shift-Escape to fire up the task manager. Select and close the application that is not responding.
- Mac – Press Option-Command-Escape to fire up the force quit dialog box. Select and close the application that is not responding.
FORCE POWER OFF
If the shutdown commands will not even work, the last straw is to call for a hard power off – Press and hold the power button for at least 4 seconds to force a power down; This is a function on the motherboard and not the operating system… If it still does not power down, it might be a hardware problem instead of software.
LINKS & REFERENCES
Thank you for reading, and we have come to the end of this guide. I hope that this has helped you to better understand, and if you have anything to share with this guide, please feel free to comment below. Good luck and happy blogging. May the force be with you.