Skip to main content
Commands

Linux Shutdown Command: 5 Practical Examples

The shutdown command in Linux allows you to shut down, reboot or schedule a shutdown of your system. This article explains the most common and useful examples of the Linux shutdown command.

Abhishek Prakash

There is a dedicated command to shut down a system in Linux. It is unsurprisingly called shutdown.

Before seeing the usage of the shutdown command, let’s first see its syntax.

shutdown [options] [time] [message]

Note: The shutdown command needs superuser privileges. Hence, you should either be root or run the command with sudo.

5 practical examples of shutdown command in Linux

Now that you know the syntax of the shutdown command let’s see how to use it.

If you simply use the shutdown command, it will start the shutdown process after one minute. So remember that the default time interval for shutdown command in one minute.

sudo shutdown
Shutdown scheduled for Mon 2018-11-19 11:33:36 UTC, use 'shutdown -c' to cancel.

Unsuspecting Linux users expect the shutdown command to immediately shut down the system but when they see a message like this with timestamp in UTC, they often get confused.

1. Shutdown the system immediately

You don’t always have to wait one minute for the system to shutdown. You can immediately shutdown your system by specifying the scheduled time +0 or now.

sudo shutdown now

2. Schedule a system shutdown

You can schedule a shutdown in future by providing the time argument either in +t format or in hh:mm format.

For example, if you want to shutdown the system after 15 minutes, you can use this command:

sudo shutdown +15

If you want to shutdown the system at 4 PM in the afternoon, you can use it in the following manner:

sudo shutdown 16:00

Needless to say that the reference time and timezone is the system time itself.

Five minutes before the scheduled shutdown, the system won’t allow any login activity. Which means a new user cannot log on to the system within five minutes of the scheduled shutdown.

3. Restart the system with shutdown command

There is a separate reboot command but you don’t need to learn a new command just to restart the system. You can use the Linux shutdown command for rebooting as well.

To reboot a Linux system using the shutdown command, use the -r option.

sudo shutdown -r

The behavior is the same as the regular shutdown command. It’s just that instead of a shutdown, the system will be restarted.

So, if you used shutdown -r without any time argument, it will schedule a reboot after one minute.

You can schedule reboots the same way you did with shutdown.

sudo shutdown -r +30

You can also reboot the system immediately with shutdown command:

sudo shutdown -r now

4. Broadcast a shutdown message

If you are in a multi-user environment and there are several users logged on the system, you can send them a custom broadcast message with the shutdown command.

By default, all the logged users will receive a notification about scheduled shutdown and its time. You can customize the broadcast message in the shutdown command itself:

sudo shutdown 16:00 "systems will be shutdown for hardware upgrade, please save your work"
Fun Stuff: You can use the shutdown command with -k option to initiate a ‘fake shutdown’. It won’t shut down the system but the broadcast message will be sent to all logged on users. K stands for kidding.

5. Cancel a scheduled shutdown

If you scheduled a shutdown, you don’t have to live with it. You can always cancel a shutdown with option -c.

sudo shutdown -c

And if you had broadcasted a messaged about the scheduled shutdown, as a good sysadmin, you might also want to notify other users about cancelling the scheduled shutdown.

sudo shutdown -c "planned shutdown has been cancelled"

Bonus: Filesystem check at reboot

You can force a filesystem check at the next reboot with the -F option. So if you use it with any of the above mentioned options of shutdown command, it will do a filesystem check when the system starts again.

Similarly, you can use the flag -f to skip the filesystem check.

Bonus: Halt vs Power off

Halt (option -H): terminates all processes and shuts down the cpu.
Power off (option -P): Pretty much like halt but it also turns off the unit itself (lights and everything on the system).

Historically, the earlier computers used to halt the system and then print a message like “it’s ok to power off now” and then the computers were turned off through physical switches.

These days, halt should automatically power off the system thanks to ACPI.

These were the most common and the most useful examples of the Linux shutdown command. I hope you have learned how to shut down a Linux system via command line. You might also like reading about the less command usage or browse through the list of Linux commands we have covered so far.

If you have any questions or suggestions, feel free to let me know in the comment section.

Abhishek Prakash