Dec 042015
 

If you love tinkering with Linux, here’s something to pique your interest.

In this post, we’ll look at various methods to shut down or reboot a Linux system via the terminal.

Shutdown, poweroff, and reboot are three commands to shut down or reboot a Linux system.

I recommend you install Oracle’s free Virtualbox virtualization software and then install a guest OS (CentS or Ubuntu) before running the below commands on it to avoid accidentally disrupting important running processes.

Shut Down Linux

There are multiple options to shut down a Linux system on the command line.

Let’s first consider the shutdown and poweroff commands.

You can use the shutdown command to both shut down and reboot a Linux system.

First, we’ll look at the commands to shut down the system and then run through the commands for rebooting.

$ shutdown
Must be root.

As we see above, we need to be root or use sudo to run the shutdown command.

So we’ll run the command again, this time with sudo.

[jason@localhost ~]$ sudo shutdown
[sudo] password for jason: 
Shutdown scheduled for Thu 2015-12-03 21:02:24 EST, use 'shutdown -c' to cancel.
[jason@localhost ~]$ 
Broadcast message from root@localhost.localdomain (Thu 2015-12-03 21:01:25 EST):
The system is going down for power-off at Thu 2015-12-03 21:02:24 EST!

As we note above, the system provides users with advance notice of the impending power-off.

Shut Down Immediately

$ sudo shutdown now

When you run the above command, the system will shut down immediately so make sure you have everything saved and no important processes running.

Delayed Shut Down
Say you want to shut down your Linux system after three minutes.

Here’s the command for that.

[jason@localhost ~]$ sudo shutdown 3
[sudo] password for jason: 
Shutdown scheduled for Thu 2015-12-03 22:55:16 EST, use 'shutdown -c' to cancel.
Broadcast message from root@localhost.localdomain (Thu 2015-12-03 22:53:16 EST):
The system is going down for power-off at Thu 2015-12-03 22:55:16 EST!

You can even specify the exact time for the system to be shut down.

[jason@localhost ~]$ sudo shutdown 11:45
Shutdown scheduled for Fri 2015-12-04 11:45:00 EST, use 'shutdown -c' to cancel.
[jasoni@localhost ~]$ 
Broadcast message from root@localhost.localdomain (Fri 2015-12-04 11:35:27 EST):
The system is going down for power-off at Fri 2015-12-04 11:45:00 EST!

Remember to use 24-hour time for PM (so for a scheduled shut down at 1:35PM you must write sudo shutdown 13:35).

Cancel Shut Down

What if you change your mind.

There’s the cancel option unless you set an immediate shut down.

[manvi@localhost ~]$ sudo shutdown -c
Broadcast message from root@localhost.localdomain (Fri 2015-12-04 09:52:36 EST):
The system shutdown has been cancelled at Fri 2015-12-04 09:53:36 EST!

Poweroff
You can also use poweroff to shut down a system.

$ sudo poweroff

Before you can blink your eyes, the system will be shut down/powered off with the above command.

Reboot Linux

Now we’ll look at rebooting a Linux system via the terminal.

Again, there are multiple ways to do it.

[jason@localhost ~]$ sudo shutdown -r
[sudo] password for jason: 
Shutdown scheduled for Thu 2015-12-03 21:52:33 EST, use 'shutdown -c' to cancel.
[jason@localhost ~]$ 
Broadcast message from root@localhost.localdomain (Thu 2015-12-03 21:51:33 EST):
The system is going down for reboot at Thu 2015-12-03 21:52:33 EST!

Let’s now try the reboot command.

$ sudo reboot

Be careful with the above and below commands because the system will reboot immediately.

$ sudo poweroff --reboot

Delayed Reboot

The below command will reboot the system after three minutes.

$ sudo shutdown -r 3
Shutdown scheduled for Fri 2015-12-04 10:17:06 EST, use 'shutdown -c' to cancel.
Broadcast message from root@localhost.localdomain (Fri 2015-12-04 10:14:06 EST):
The system is going down for reboot at Fri 2015-12-04 10:17:06 EST!

Hope you found the shut down and reboot commands useful.

Adios!

We’ll be back soon.

 Posted by at 12:54 pm

Sorry, the comment form is closed at this time.