General

How To: Shutdown Linux From The Terminal

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 CTRL + ALT + F3. That should crack open a TTY where you can login and issue commands to your system. Maybe you’re working on a server and need to shut it down? Who knows, but the command is there and it’s a useful command to keep in mind.

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 CTRL + ALT + T and your default terminal should open.

Once you’re ready to shutdown your Linux system, you can enter the following to shutdown immediately:

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):

sudo shutdown HH:MM

You can also use the +MM function. To shutdown in 10 minutes, you’d use a command like this:

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:

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.

sudo shutdown -c

If your cancellation will impact the users, you can even include a message in that. It’s done like this:

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.

KGIII

Retired mathematician, residing in the mountains of Maine. I may be old and wise, but I am not infallible. Please point out any errors. And, as always, thanks again for reading.

View Comments

  • 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!

Recent Posts

View Detailed Hardware Information

There are many tools for showing your hardware information and today we'll get to view…

2 days ago

How To: Install Wine In Lubuntu

Today's article isn't going to be complicated or long as we are going to cover…

3 days ago

Update Python Packages (PIP)

We've had a run of Python packages recently and you can tell that I'm a…

6 days ago

Save A Command’s Output To A File (While Showing It In The Terminal)

The title is the best I can come up with to describe this exercise as…

1 week ago

Demystifying journalctl: A Comprehensive Guide to Linux System Logging

It was suggested that I write an article about journalctl, which seemed like a large…

1 week ago

Extract Text From Multiple File Types

Today we will have a fairly simple exercise as we're going to just use a…

2 weeks ago