How to shutdown a server with cmd

Have you ever wanted to shut down a Windows server using command line, so you won’t have to take the time to access the server’s motherboard and just do it directly from the operating system? This tutorial will show you how.

In this post we will learn how to shutdown a server with cmd, shutdown command in linux and shutdown command windows 10. We can use following command to shutdown the server.

How to shutdown a server with cmd

The shutdown command is a Command Prompt command that powers off, restarts, logs off, or hibernates your computer. The same one can be used to remotely shut down or restart a computer you have access to over a network.

In some ways, it’s similar to the logoff command.

Shutdown Command Availability

Illustration of a person issuing the shutdown command on a Windows computer
Maddy Price / Lifewire 

The shutdown command is available from the Command Prompt in Windows 11, Windows 10, Windows 8, Windows 7, Windows Vista, and Windows XP operating systems.

Shutdown Command Syntax

The command follows the following syntax:

shutdown [/i | /l | /s | /r | /g | /a | /p | /h | /e | /o] [/hybrid] [/f] [/m \\computername] [/t xxx] [/d [p:|u:]xx:yy] [/c “comment] [/?]

If you don’t know how to read command syntax, below is a breakdown of what all that means.

The availability of certain command switches and other syntax may differ from operating system to operating system.

Shutdown Command Options
ItemDescription
/iThis shutdown option shows the Remote Shutdown Dialog, a graphical version of the remote shutdown and restart features available in the command. The /i switch must be the first switch shown and all other options will be ignored.
/lThis option will immediately log off the current user on the current machine. You can not use the /l option with the /m option to log off a remote computer. The /d/t, and /c options are also not available with /l.
/sUse this option with the shutdown command to shut down the local or /m defined remote computer.
/rThis option will shut down and then restart the local computer or the remote computer specified in /m.
/gThis shutdown option functions the same as the /r option but will also restart any registered applications after the reboot.
/aUse this option to stop a pending shutdown or restart. Remember to use the /m option if you’re planning on stopping a pending shutdown or restart that you executed for a remote computer.
/pThis command option turns off the local computer completely. Using the /p option is similar to executing shutdown /s /f /t 0. You can not use this option with /t.
/hExecuting the shutdown command with this option immediately puts the computer you’re on into hibernation. You can not use the /h option with the /m option to put a remote computer into hibernation, nor can you use this option with /t/d, or /c.
/eThis option enables documentation for an unexpected shut down in the Shutdown Event Tracker.
/oUse this switch to end the current Windows session and open the Advanced Boot Options menu. This option must be used with /r. The /o switch is new beginning in Windows 8.
/hybridThis option performs a shutdown and prepares the computer for fast startup. The /hybrid switch is new beginning in Windows 8.
/fThis option forces running programs to close without warning. Except with the /l/p, and /h options, not using shutdown’s /f option will present a warning about the pending shutdown or restart.
/m \\computernameThis command option specifies the remote computer that you want to execute a shutdown or restart on.
/t xxxThis is the time, in seconds, between the execution of the shutdown command and the actual shutdown or restart. The time can be anywhere from 0 (immediately) to 315360000 (10 years). If you don’t use the /t option then 30 seconds is assumed. The /t option is not available with either the /l/h, or /p options.
/d [p:|u:]xx:yyThis records a reason for the restart or shutdown. The p option indicates a planned restart or shutdown and the u a user defined one. The xx and yy options specify major and minor reasons for the shutdown or restart, respectively, a list of which you can view by executing the shutdown command without options. If neither p nor u are defined, the shutdown or restart will be recorded as unplanned.
/c “commentThis command option allows you to leave a comment describing the reason for the shutdown or restart. You must include quotes around the comment. The maximum length of the comment is 512 characters.
/?Use the help switch with the shutdown command to show detailed help about the command’s several options. Executing shutdown without any options also displays the help for the command.

Each time Windows is shut down or restarted manually, including through the shutdown command, the reason, type of shutdown, and [when specified] comment are recorded in the System log in Event Viewer. Filter by the USER32 source to find the entries.

Shutdown Command Examples

Here are a few examples that show how to use the shutdown command:

Restart and Record Reason

shutdown /r /d p:0:0

In the above example, the shutdown command restarts the computer that’s currently being used and records a reason of Other (Planned). The restart is designated by /r, and the reason is specified with the /d option, with p representing that the restart is planned and the 0:0 indicating an “Other” reason.

Remember, major and minor reason codes on a computer can be displayed by executing shutdown without options and referencing the Reasons on this computer table that’s displayed.

Log Out Immediately

shutdown /l

Using the shutdown command shown here, the current computer is immediately logged off. No warning message is displayed.

Shut Down Remote Computer

shutdown /s /m \\SERVER /d p:0:0 /c "Planned restart by Tim"

In the above shutdown command example, a remote computer named SERVER is shut down with a recorded reason of Other (Planned). A comment is also recorded as Planned restart by Tim. Since no time is designated with the /t option, the shutdown will begin on SERVER 30 seconds after executing the shutdown command.

Shut Down Local Computer

shutdown /s /t 0

This shutdown command is used to shut down the local computer immediately since we designated a time of zero with the shutdown /t option.

You could easily change the zero in this command to 10 to delay the shutdown for several seconds, 60 to make the computer shut down in one minute, etc.

Cancel Pending Shutdown

shutdown /a

Finally, in this last example, the shutdown command is canceled before it can complete. It applies to any restart or shutdown command. You might use it to cancel something like a timed restart scheduled for, say, two minutes from now.

Shutdown Command & Windows 8

Microsoft made it more difficult to shut down Windows 8 than they did with previous versions of Windows, prompting many to search out a way of shutting down through a command.

You can certainly do that by executing shutdown /p, but there are several other, albeit more accessible, ways of doing so.

To avoid commands altogether, you can install one of the best start menu replacements for Windows 8 to make it easier to shut down and restart the computer.

shutdown command in linux

The recommend and secure way to shutdown Linux desktops, Laptops, routers, and server is to use the shutdown command. Another option is to use halt or poweroff command. This page explains how to shutdown Linux based system using the command line.

Tutorial details
Difficulty levelEasy
Root privilegesYes
RequirementsLinux terminal
CategorySystem Management
OS compatibilityAlma • Alpine • Arch • Debian • Fedora • Linux • Mint • openSUSE • RHEL • Rocky • Stream • SUSE • Ubuntu • WSL
Est. reading time3 minutes

ADVERTISEMENT

Linux system shutdown

To shutdown Linux using the command line:

  1. To shutdown the Linux system open a terminal application.
  2. Then type “sudo shutdown -n now” to shutdown the box.
  3. Then wait for some time and the Linux server will poweroff.
  4. Are you using systemd based Linux distro? Try the following command:
    sudo systemctl poweroff
How To Shutdown Linux System


Let us see all examples and syntax in details.

Reboot Linux system command syntax

The syntax is:
shutdown -h time "message"
Where,

  • -h : Poweroff the system.
  • time : When to shutdown. You can poweroff immediately or after 2 minutes. It can be an absolute time in the format hh:mm, in which hh is the hour (1 or 2 digits) and mm is the minute of the hour (in wo digits). Second, it can be in the format +m, in which m is the number of minutes to wait. The word now is an alias for +0.
  • message: Send warning message to send to all users.

Steps to shutdown the Linux server system

First, open a command-line terminal (select Applications > Accessories > Terminal). For remote system, login using the ssh command. Next, switch to the root user by typing su - or sudo -s and entering the root password, when prompted. Finally, type the following command to shutdown system immediate as root user:
# shutdown -h now
OR
# shutdown -h +0
Of course, one can use the sudo command as follows:
$ sudo shutdown -h now
Similarly, modern Linux distros with systemd can use the following command too:
$ sudo systemctl poweroff

Shutting down the Linux box with warning message

To shutdown system in 10 minutes with the following warning message:
# shutdown -h +10 "Development server is going down for maintenance. Please save your work ASAP."
Here is what all users will see on their terminal:

Broadcast message from root@wks01 (pts/0) (Sat Apr 21 02:26:30 2012):


Development server is going down for maintenance. Please save your work ASAP. 
The system is going DOWN for system halt in 10 minutes!

Want to cancel a pending shutdown command?

Pass the -c from another terminal session. For instance:
$ sudo shutdown -c

Say hi to poweroff command

You can halt the system, switch off the power. This is called as poweroff and poweroff command can be used as follows (warning: the following command will immediately shutodown the Linux system):
# poweroff

How to see log of my Linux system shutdown

The last reboot or last shutdown command will show a log of all reboots and shutdown since the log file was created under Linux:
# last reboot
OR
# last shutdown
# last -x shutdown

Sample outputs:

shutdown system down  2.6.32-131.12.1. Sun Jan  1 05:03 - 05:05  (00:02)    
shutdown system down  2.6.32-131.12.1. Sun Aug 28 16:53 - 17:00  (00:06)    
shutdown system down  2.6.32-131.12.1. Sat Aug 27 17:21 - 17:23  (00:02)    
shutdown system down  2.6.32-131.0.15. Sat Aug 27 17:15 - 17:18  (00:02)    

wtmp begins Sat Aug 27 17:08:12 2011

shutdown command windows 10

Below are some ways to restart your Windows 10 device. 

1. Shut down or restart Windows 10 using the Start Menu

The simplest and most basic method of closing down Windows 10 is by using the Start Menu, which is the default option in the latest Microsoft operating system. To do this, first open the Start Menu by clicking or tapping the Windows button on the bottom left corner of the screen. Then, click or tap the Power button. From the options that appear choose Restart to reboot the device or Shut down to shut it down completely.

  |

Shut down or restart Windows 10 from the Start Menu

If the Start Menu is set to fullscreen mode, or if you’re using Windows 10 in tablet mode, things look a bit different, but you still need to tap the same Start button to access the Start Menu and open its Power sub-menu.

  |

Shut down or restart Windows 10 from the Start screen

2. Shut down or restart Windows 10 using the WinX menu

You can also access the power user menu, also known as the WinX menu, by pressing the Windows + X keys on your keyboard, or by right-clicking (long pressing) on the Windows button from the bottom-left corner of your desktop. On the WinX menu, press “Shut down or sign out” to access Shut down or Restart.

  |

Shut down or restart Windows 10 from the WinX Menu

3. Shut down or restart Windows using “Alt + F4”

Whenever the focus in Windows 10 is on the desktop, you can press the Alt + F4 keys on your keyboard to open the shutdown menu. In the Shut Down Windows dialog window, you can open the drop-down list to choose whether to shut down, restart or put the device to sleep.

You can also log out from your user profile or switch to a different one. Select the option you want, and click or tap OK to confirm it.

  |

Shut down or restart Windows 10 from the Shut Down Windows dialog window

4. Shut down or restart Windows 10 using the “shutdown” command

If you like using command line interfaces for everything you do, you can also use Command Prompt or PowerShell to close Windows 10. You can execute the same command from a Run window. Open a Command Prompt, PowerShell or Run window, and type the command “shutdown /s” (without quotation marks) and press Enter on your keyboard to shut down your device.

  |

Shut down Windows 10 using shutdown command

In a few seconds, Windows 10 shuts down, and it is displaying a window that tells you that it is going to “shut down in less than a minute.” Please note that closing this window does not stop the shutdown process.

  |

Shut down warning for shutdown command

Change the parameter of the command from /s to /r (“shutdown /r”), and the Windows 10 device restarts instead of just shutting down. The command displays the same warning window as above (“You’re about to be signed out”).

  |

Restart Windows 10 using the shutdown command

5. Shut down or restart Windows using the PowerShell “Stop-Computer” and “Restart-Computer” commands

PowerShell has its commands, also known as cmdlets, to shut down or restart a Windows 10 device. “Stop-Computer” shuts down the Windows 10 system.

  |

Shut down Windows 10 using Stop-Computer cmdlet in PowerShell

The command “Restart-Computer” executes a restart.

  |

Restart Windows 10 using Restart-Computer cmdlet in PowerShell

6. Shut down or restart Windows 10 from the lock screen

You can also shut down your device from the lock screen: you can see this screen before logging into Windows 10, or if you sign out or lock your device.

On it, press the I/O icon from the bottom-right corner to access the shut down, restart and sleep options.

  |

Shut down or restart Windows 10 from the lock screen

7. Shut down or restart Windows 10 from the “Control + Alt + Delete” screen

If you use a Windows 10 PC with a keyboard, you can use the “Control + Alt + Delete” screen to access the power options. Simultaneously press the Control, Alt and Delete keys on your keyboard and then click or tap on the I/O button from the bottom-right corner of the screen.

  |

Shut down or restart Windows 10 from the Control + Alt + Delete screen

The usual menu opens with options for Sleep, Shut down and Restart. Click or tap the one you want.

Leave a Comment