How to Restart Computer From CMD (Windows & Mac)

INTRODUCTION

RESTART TROUBLE?

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!

 

 

 

SECTION A

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 or 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 /s Shuts down the computer.
  • shutdown /r Restarts the computer.
  • shutdown /l Log off.
  • shutdown /h Hibernate.

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.

 

 

SECTION B

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 OPTIONS

  • shutdown -h Halt the system.
  • shutdown -r Reboot the system.
  • shutdown -s Put the system into sleep mode.
  • shutdown -k More for Mac server usage. Does not shut down, but kick everyone off the system.

 

SHUTDOWN TIME

The shutdown time is required, and there are generally 3 ways to define it:

  • shutdown -h now Right now.
  • shutdown -h 12:34 An exact time.
  • shutdown -h +15 Specified minutes later.

 

SHUTDOWN MESSAGE

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 -h is equals to calling halt
  • shutdown -r is equals to calling reboot

But not really… It’s kind of confusing. But shutdown, halt, and reboot all belong to the same system module that deals with shutting down and rebooting.

 

 

SECTION C

EXTRA BITS

That’s it for the shutdown commands, and here are a few extra bits that may be useful to you.

 

FORCE QUIT

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.

 

CHEAT SHEET

How to Restart Computer From CMD (click to enlarge)

 

LINKS & REFERENCES

 

 

CLOSING

WHAT’S NEXT?

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.

Leave a Comment

Your email address will not be published. Required fields are marked *