Command-line Basics: Shutdown and Reboot

Published on May 17, 2019


    Command-line Basics: Shutdown and Reboot

    While we believe that this content benefits our community, we have not yet thoroughly reviewed it. If you have any suggestions for improvements, please let us know by clicking the “report an issue“ button at the bottom of the tutorial.

    When you’re in the same room as a server, shutting it down or rebooting it is simple. You could hold the power button or even unplug the whole machine. Not only are these solutions inelegant, they have the potential to corrupt your data and potentially damage your hardware! They also don’t work when you’re logged into your favorite remote server.

    Depending on your hosting provider, you very well may have a nice GUI interface at your disposal, completely with a shiny red button to shutdown or reboot the machine. It’s a sufficient solution, but doesn’t necessarily scale across different hosting providers.

    Knowing how to do things on the command-line allows you to be as stack agnostic as possible. You can switch easily between hosting providers and always have the same consistent set of tools at your disposal. This flexibility comes in extra handy when you’re working with a brand new stack that you’re not familiar with.

    Getting started

    The commands discussed in this article, shutdown and reboot do exactly as their names imply. They will shut down or reboot your machine. Because these are somewhat destructive commands, if you run them locally, be ready for your system to system to shut down or reboot.

    Using a remote development or staging server running a Unix-like operating system (like Linux) would be an ideal scenario. Because you will in fact take your server off line with these commands, I wouldn’t recommend running them on a production server unless you really want to reboot the box.

    The following commands will more than likely require elevated super-user privileges to run. If you receive an error about a command not being found, just try it again with sudo.

    If you don’t have super-user privilege on the machine you’re on, you more than likely won’t be able to shut it down or reboot it.

    Shutting down

    Shutting down a system can be done with the shutdown command, in it’s simplest form, without any arguments:

    $ shutdown # Graceful shutdown in 1 minute

    Without any arguments, the shutdown command will schedule the shutdown for a minute out from the current time. Because it’s scheduled in the future, you have a window of opportunity to cancel the shutdown by way of the -c argument:

    $ shutdown -c # Cancel a scheduled shutdown

    Crisis averted!

    You may have noticed that a broadcast message was issued when you ran the first shutdown command. That’s the wall message, and it’s issued to all of the users that are currently logged into the system.

    The time of the shutdown can be scheduled, as well as the content of the wall message that is presented to your users:

    $ shutdown now "Cya later alligator" # Immediately shut down
    $ shutdown +5 "Cya later alligator"  # Shutdown in 5 minutes

    Because the arguments are passed in order and without additional --flags to indicate what the values are, they must be passed in a specific order. That means you can’t customize the wall message without also specifying a time.


    If you are just looking for a quick and easy way to reboot a server, the reboot command is about as easy as it comes:

    $ reboot    # Graceful restart
    $ reboot -f # Forceful, like holding the power button

    In tune with the Unix Philosophy, the reboot command does what it’s name implies and not much else.

    The shutdown command on the other hand, actually does a bit more than the “shutdown” name infers, by allowing you to use it to reboot a machine as well as shut it down.

    Why this is important is that while the reboot command is quick and gets the job done, using the shutdown command to restart your machine gives you the added benefit of being able to schedule things as well as edit the wall message.

    To tell the shutdown command to reboot instead of just shutting down, pass in the -r or --reboot argument, along with any other options:

    $ shutdown --reboot                       # Reboot in 1 minute
    $ shutdown -r now "After while crocodile" # Immediately reboot
    $ shutdown -r +5 "After while crocodile"  # Reboot in 5 minutes

    Similar to how we canceled a full shutdown earlier, another added benefit over reboot is that you can also cancel a reboot via shutdown by calling it again with the -c argument:

    $ shutdown -c # Cancel a scheduled shutdown (or reboot!)

    Thanks for learning with the DigitalOcean Community. Check out our offerings for compute, storage, networking, and managed databases.

    Learn more about our products

    About the authors
    Default avatar


    Still looking for an answer?

    Ask a questionSearch for more help

    Was this helpful?

    This textbox defaults to using Markdown to format your answer.

    You can type !ref in this text area to quickly search our full set of tutorials, documentation & marketplace offerings and insert the link!

    my server stock at shutdown what should I do

    Try DigitalOcean for free

    Click below to sign up and get $200 of credit to try our products over 60 days!

    Sign up

    Join the Tech Talk
    Success! Thank you! Please check your email for further details.

    Please complete your information!

    Featured on Community

    Get our biweekly newsletter

    Sign up for Infrastructure as a Newsletter.

    Hollie's Hub for Good

    Working on improving health and education, reducing inequality, and spurring economic growth? We'd like to help.

    Become a contributor

    Get paid to write technical tutorials and select a tech-focused charity to receive a matching donation.

    Welcome to the developer cloud

    DigitalOcean makes it simple to launch in the cloud and scale up as you grow — whether you're running one virtual machine or ten thousand.

    Learn more
    DigitalOcean Cloud Control Panel