The “shutdown” Command in Linux [7 Practical Examples]

The shutdown command in Linux is useful for safely shutting down the system. The machine can be shut off immediately or on a schedule with a 24-hour format. It securely shuts down the system. In this article, I will describe all the features and uses of the shutdown command in Linux with multiple examples.

A. Description

Shutdown refers to stopping or shutting down a computer or service. When executing the shutdown command, all currently active users and processes are informed that the system is shutting down. New login attempts are not permitted when the shutdown is initiated. You can shut down your system immediately or schedule a specified time for shutdown.

B. Syntax

The syntax of the shutdown command in Linux  is very simple and is as below:

shutdown [OPTIONS]... [TIME] [MESSAGE]
Note: In the syntax above square bracket means the OPTIONS are not mandatory and three dots after the square bracket means multiple OPTIONS can be used after the shutdown command.

C. Options

There are many useful options available for the shutdown command. I have listed some of the most commonly used options, which are given below. You can learn more about options and their uses by checking the man page.

man shutdown

Useful Options

  • -r: Asks for the system to be restarted following a shutdown.
  • -h: Equivalent to halt unless power is off depending on the specified option.
  • -H: Stop the operating system.
  • -P: Power off the machine.
  • -c: Cancel a shutdown that is currently in effect. This can be used to invoke a shutdown with a time argument other than “+0” or “now.”
  • -k: Do not halt, power off or reboot, only send out the warning messages.
Note: Commands and their options are case-sensitive in Linux. So, be cautious while using them.

Practical Examples of the “shutdown” Command in Linux

The shutdown is a helpful command that shuts down the system securely. In the section below, I will show you some of the most useful applications for the shutdown command in Linux.

Example 1: Shutdown the System With the “shutdown” Command in Linux

It is the simplest form of the shutdown command, without any arguments or options. It will take about one minute to shut down the system. You can shut down your system with this command by following the steps below.

Steps to Follow >

➊ At first, open the Ubuntu Terminal.

 Type the following command into the command prompt:

sudo shutdown

➌ Now, press the ENTER button.

➍ Enter your user PASSWORD.

Output >

The system will take about one minute to shutdown. That means you have to wait one minute to shut down your system.Picture showing the result of scheduling a simple shutdown with shutdown command in linux.


Similar Readings


Example 2: Shutdown the System Immediately

The shutdown command, with the time argument “0” shuts down the system immediately. Here, I will shut down the system immediately using the shutdown command. You can do the same with this command by following the steps below.

Steps to Follow >

➊ At first, open the Ubuntu Terminal.

 Type the following command into the command prompt:

sudo shutdown +0

OR,

sudo shutdown now
Note: “now” is the alias of ‘+0’ ( which denotes the value of time arguments).

➌ Now, press the ENTER button.

➍ Enter your user PASSWORD.

Output >

When you press ENTER after typing your user PASSWORD the system will shut down immediately.Picture showing the process of scheduling a immediate shutdown with shutdown command in linux.

Example 3: Shutdown the System at a Specified Time

The shutdown command, with a time argument, allows you to shut down your system at a specific time, mentioned as the argument value. I’m going to schedule the shutdown at 5:00 PM. You can do the same by following the steps below.

Steps to Follow >

➊ At first, open the Ubuntu Terminal.

 Type the following command into the command prompt:

sudo shutdown 17:00

➌ Now, press the ENTER button.

➍ Enter your user PASSWORD.

Output >

In the following image, you can see the shutdown time has been scheduled for 05:00 PM. You would see the output as below if you followed the above-mentioned instructions.Picture showing the result of scheduling a shutdown at a specific time.


Similar Readings


Example 4: Shutdown the System After a Specified Time

The shutdown command in Linux also allows you to shut down your system after a specific time, mentioned as the argument value. I am currently scheduling the shutdown time after 40 minutes. You can do the same by following the steps below.

Steps to Follow >

➊ At first, open the Ubuntu Terminal.

 Type the following command into the command prompt:

sudo shutdown +40

➌ Now, press the ENTER button.

➍ Enter your user PASSWORD.

Output >

In the below image, you can see that I scheduled a shutdown after 40 minutes from now. After doing the same, you will see the following message in the terminal.Picture showing the process of scheduling a shutdown after a specific time with shutdown command in linux.

Example 5: Halt the System With the “shutdown” Command in Linux

Mainly, halt means stopping CPUs, and powering off also to ensure that the power gets disconnected. You can halt your system by following the following steps.

Steps to Follow >

➊ At first, open the Ubuntu Terminal.

 Type the following command into the command prompt:

sudo shutdown -H

➌ Now, press the ENTER button.

➍ Enter your user PASSWORD.

Output >

After following the above steps you will receive the following notification in your system terminal.Picture showing the process of scheduling a halt with shutdown command in linux.

If you are using VM on your computer, you will get another notification like the one below.Picture showing the notice of VM after scheduled a halt.

Similar Readings


Example 6: Reboot Using the “shutdown” Command in Linux

Linux allows you to reboot your system after a specific time that you decide to reboot. For this, you have to add -r options with the shutdown command. Here, I will show you an example that you can follow.

Steps to Follow >

➊ At first, open the Ubuntu Terminal.

 Type the following command into the command prompt:

shutdown -r +5

➌ Now, press the ENTER button.

Output >

In the following image, you can see that I set the reboot to occur after 5 minutes, hence it will start the system after a shutdown.

Picture Showing the process of scheduling a reboot with shutdown command in linux.


Similar Readings


Example 7: Cancel a Scheduled Shutdown

As you can schedule a shutdown time, you can also cancel the scheduled shutdown. To cancel a scheduled shutdown, you have to follow the steps below.

Steps to Follow >

➊ At first, open the Ubuntu Terminal.

 Type the following command into the command prompt:

shutdown -c

➌ Now, press the ENTER button.

Output >

In the following image, If you follow the time carefully, you can see that the scheduled reboot time is over but the system didn’t reboot, which means the scheduled shutdown is canceled due to the shutdown -c command.Picture showing " how to cancel a scheduled shutdown or reboot."

Conclusion

In this article, I’ve shown the operation of the shutdown command. I’ve also provided some relevant examples. You should be able to use the shutdown command effectively on your own if you properly read this article and follow the above-mentioned guidelines.


Similar Readings

Rate this post
S. M. Amdadul Islam

Hello everyone. I am S. M. Amdadul Islam, currently working as a Linux Content Developer Executive at SOFTEKO. I am a Naval Architecture and Marine Engineering (NAME) graduate from the Bangladesh University of Engineering and Technology. In addition to my regular work, I enjoy watching Youtube, discovering new things, gossiping with friends, visiting new places, and taking photos of landscapes. Read Full Bio

Leave a Comment