How To Reboot Linux Using The Command Line

Shutdown Your Linux Computer
Shutdown Your Linux Computer.


In this guide I am going to show you how to shutdown and reboot your system using the Linux command line.

Most people use graphical desktop environments nowadays and therefore they shutdown using the relevant menu option.

If you have a single board computer such as the Raspberry PI or you are running a headless computer (one without a display) then you might want to know how to shut the computer down and restart it without physically pulling the power.

How To Shutdown Your Computer Using The Linux Terminal

The command required to shutdown your machine is as follows:


It is highly likely that you need to have elevated privileges to use the shutdown command so you are more likely to use the sudo command as follows:

sudo shutdown

The output from the above command will say something along the lines of "shutdown scheduled for <time>, use shutdown -c to cancel".

Generally it is better to specify when you want the computer to shutdown. If you want the computer to shutdown immediately use the following command:

sudo shutdown now

The time element can be specified in a number of ways. For example you could use the following command to also shutdown the computer immediately:

sudo shutdown 0

The number refers to the number of minutes to wait before the system attempts to shut down.

Incidentally the command sudo shutdown without any time element is the equivalent to running the following command:

sudo shutdown 1

The default therefore is 1 minute.

You can also specify a set time in hours and minutes to shut down your computer as follows:

sudo shutdown 22:00

When the amount of time until shut down is less than 5 minutes the system will not allow any more users to login.

If you are running a system with multiple users you can specify a message which will appear on all users screens letting them know that a shutdown is going to occur.

sudo shutdown 5 "save your work, system going down"

For completeness there is another switch you can use which is as follows:

sudo shutdown -P now

Technically you don't need to use the -p as it actually stands for poweroff and the default action for shutdown is to poweroff. If you want to guarantee that the machine powers off and doesn't just halt then use the -P switch.

If you are better at remembering words over switches you might prefer to use the following:

sudo shutdown --poweroff now

How To Reboot Your Computer Using The Linux Command Line

The command for rebooting your computer is also shutdown. There is actually a reboot command as well which is used for legacy purposes and logically speaking is a more obvious command to use to reboot your computer but most people actually use the following command to reboot their computer:

sudo shutdown -r

The same rules apply to the reboot command as they do for the shutdown command.

What this means is that by default the shutdown -r command on its own will reboot the computer after 1 minute.

To reboot immediately you have to specify either of the following commands:

sudo shutdown -r 0

sudo shutdown -r now

If you want the computer to reboot in 5 minutes you can specify the following command:

sudo shutdown -r 5

You can also specify a time to reboot the computer in hours and minutes as follows:

sudo shutdown -r 22:00

Finally as with the shutdown procedure you can specify a message to be displayed to all users of the system letting them know the system is going down.

sudo shutdown -r 22:00 "the system is going to bounce. Boing!!!"

If you prefer to you can use the following instead of the -r switch:

sudo shutdown --reboot now

Make The System Halt

You can specify one more command which shuts down the operating system but doesn't actually power off the machine.

The command is as follows:

sudo shutdown -H

You can also use the following command:

sudo shutdown --halt

How To Cancel A Shutdown

If you have scheduled a shutdown for the future then you can actually cancel the shutdown using the following command:

shutdown -c

If you have used either shutdown now or shutdown 0 then this won't have time to work.


For completeness you might want to check out the manual pages for these legacy commands:

More From Us