Today’s article is going to tell you how to shutdown from the terminal. I’ve previously explained how to reboot a ‘frozen’ Linux system using the Magic SysReq keys. Today, we’ll shutdown from the terminal. It’s a quick and easy article – as the holidays are eating a bit of my “free” time.
Why would you want to do this? Well, if your Linux system isn’t quite frozen or your desktop GUI isn’t something you can reach, then you may want to press something like
For this article, we’ll mostly be using the shutdown command, and the man page defines it as:
shutdown – Halt, power-off or reboot the machine
And it does pretty much what you’d expect from such a command. However, it’s not just a basic command, there are flags and some options that go along with it. So, we might as well take the time to learn about it. After all, you never know when you want to shutdown Linux from the terminal.
Shutdown Linux From The Terminal:
Like oh so many articles, this one will require an open terminal. If you’re connected to a remote server via SSH, you already have a terminal to work with. If not, just press
Once you’re ready to shutdown your Linux system, you can enter the following to shutdown immediately:
1 | sudo shutdown now |
Obviously, that command will shutdown the system immediately, so don’t practice it unless you plan on shutting down – ’cause you will. You can even shutdown at a specific time by using this format (and 24h time):
1 | sudo shutdown HH:MM |
You can also use the +MM function. To shutdown in 10 minutes, you’d use a command like this:
1 | sudo shutdown +10 |
If you change that +10 to +0, it will also shutdown immediately. If you have users of the system who should be notified of an impending shutdown, then you can actually send them a message. That would look like:
1 | sudo shutdown +<time> "<message_to_users>" |
So, what happens if you schedule a shutdown and need to stop it for some reason? Fortunately, the shutdown command will let you cancel an impending shutdown – so long as you get there in time. That’s done with the -c flag, of course.
1 | sudo shutdown -c |
If your cancellation will impact the users, you can even include a message in that. It’s done like this:
1 | sudo shutdown -c "<message_to_users>" |
And that’s about it, really. There’s a bit more to the shutdown command, but it’s mostly going to be used in one of the ways mentioned in this article. If you want more information about the shutdown command, simply run man shutdown
and read the help file.
Closure:
And there’s another article. This one will tell you how to shutdown Linux from the terminal, a handy skill to have as a user or as an admin. It may seem like a pretty basic command, but that doesn’t mean it can’t be included on the site.
Thanks for reading! If you want to help, or if the site has helped you, you can donate, register to help, write an article, or buy inexpensive hosting to start your own site. If you scroll down, you can sign up for the newsletter, vote for the article, and comment.
I like the article. The one thing you might consider is contrasting “init 6” to reboot. From my understanding this might be a more graceful way to restart a system.
I’ll have to look into that. If you’ve got a handy link or two, that’d be awesome. If not, I’ll try looking into it this coming week.
I’m a bit sluggish today. I’m pretty sure I’m coming down with something. Yay for congregating for the holidays!