How to use Linux Shutdown Command with Examples

Introduction

The Linux shutdown command is a powerful tool that allows you to shut down or reboot your Linux system. It is a versatile command that can be used in a variety of ways, from shutting down a single system to shutting down an entire network. In this guide, we will discuss the basics of the Linux shutdown command and provide some examples of how to use it. We will also discuss some of the more advanced options available with the command. By the end of this guide, you should have a good understanding of how to use the Linux shutdown command.

How to use Linux Shutdown Command with Examples

The Linux shutdown command is used to shut down or reboot a Linux system. It can be used to shut down the system immediately, or at a specified time.

Syntax

shutdown [OPTION] [TIME] [MESSAGE]

Options

-h, –help: Display help information.

-r, –reboot: Reboot the system after shutdown.

-k, –no-reboot: Do not reboot the system after shutdown.

-c, –cancel: Cancel a pending shutdown.

-P, –poweroff: Power off the system after shutdown.

Examples

1. To shut down the system immediately, use the following command:

shutdown -h now

2. To shut down the system in 10 minutes, use the following command:

shutdown -h +10

3. To reboot the system in 5 minutes, use the following command:

shutdown -r +5

4. To cancel a pending shutdown, use the following command:

shutdown -c

5. To power off the system in 15 minutes, use the following command:

shutdown -P +15
[ad_1]

Introduction

All Linux users and system administrators need to know how to shut down the entire system safely. There are several options to do so, including scheduling a shutdown at a specific time, shutting down immediately, broadcasting a unique message, and so on.

In this tutorial, learn how to use the Linux shutdown command with examples.

linux tutorial on the shutdown command with options

shutdown Command Syntax

Before going into specific ways to shut down your Linux system, you should understand the basic syntax of the shutdown command:

shutdown [options] [time] [message]
  • [options] define whether you want to halt, power-off, or reboot the machine.
  • [time] specifies when you want the shutdown to perform.
  • [message] adds a message that announces the shutdown.

How to Use the shutdown Command

To use the shutdown command on Linux systems, a  root user or a user with sudo privileges is required.

If you use the command without additional arguments, running sudo shutdown in a terminal window executes the shutdown in 60 seconds.

In the image below, see the output received after running the shutdown command.

Running the shutdown command in a Linux system

Shutdown With All Parameters

To view all parameters when shutting down the Linux system, use the following command:

sudo shutdown --help

The output displays a list of shutdown parameters, as well as a description for each.

List shutdown command with all parameters.

How to Shut Down the System at a Specific Time

To schedule a shutdown, add the [time] argument and specify when you want it to take place. There are two ways to shut down the system at a specific time – using the absolute or relative time format.

The absolute time follows the format hh:mm and allows you to schedule a shutdown at a specified time. The command follows the syntax:

sudo shutdown hh:mm

For example, to require a shutdown at 7 AM in the morning, the command is:

sudo shutdown 07:00
Schedule system shutdown at a specific time in Linux.

Alternatively, use the relative format (+m) and schedule a shutdown in a defined number of minutes from the time you run the command. In that case, the command syntax is:

sudo shutdown +m

To shut down the system in 20 minutes, run:

sudo shutdown +20
Schedule a system shutdown in the specified number of minutes.

How to Shut Down the System Immediately

As previously mentioned, running the shutdown command without any arguments prompts the system to shut down a minute after running the command. However, if you require an immediate shutdown, use:

sudo shutdown now

Another option would be to schedule a shutdown using the relative time format with the value 0, as in the command below:

sudo shutdown +0

How to Broadcast a Custom Message

Once you schedule a system shutdown, all users within the system receive a message notifying them of the shutdown. To add a custom message to the shutdown notification to inform the users what is about to take place.

You can add a [message] only if the command also includes the [time] attribute:

sudo shutdown [time] "[message]"

For instance, to shut down the system in 20 minutes and broadcast the message System Upgrade, run:

sudo shutdown +20 "System Upgrade"
Set broadcast message for a system shutdown in Linux.

Note: Another way to broadcast messages to users in Linux is via the wall command.

How to Cancel a Scheduled Shutdown

To cancel a scheduled shutdown, use the command:

sudo shutdown -c

You can also add a message to notify users that the shutdown is canceled. To do so, add the [message] option (within quotations) to the command above. For example:

sudo shutdown -c "Canceling System Upgrade"

Conclusion

This article includes all the basic shutdown commands every Linux user should know. Utilizing this command is a safe way to shut down your system. Also, it is a useful method of informing all users about scheduled shutdowns.

[ad_2]

How to Use Linux Shutdown Command with Examples

The Linux shutdown command is used to shut down or reboot a Linux system. It can be used to shut down the system immediately, or at a specific time. This article will explain how to use the shutdown command, and provide some examples.

Syntax

The syntax for the shutdown command is as follows:

shutdown [OPTIONS] TIME [MESSAGE]

The options are used to specify the type of shutdown, and the time is used to specify when the shutdown should occur. The message is an optional parameter that can be used to provide a message to users.

Options

The following options can be used with the shutdown command:

  • -h: This option is used to shut down the system immediately.
  • -r: This option is used to reboot the system immediately.
  • -k: This option is used to send a warning message to all users, but does not actually shut down the system.
  • -c: This option is used to cancel a scheduled shutdown.

Time

The time parameter is used to specify when the shutdown should occur. It can be specified in several different formats, including:

  • now: This will cause the system to shut down immediately.
  • +m: This will cause the system to shut down in m minutes.
  • hh:mm: This will cause the system to shut down at the specified time.

Examples

Here are some examples of how to use the shutdown command:

  • shutdown -h now: This will shut down the system immediately.
  • shutdown -r +5: This will reboot the system in 5 minutes.
  • shutdown -h 18:00 “The system will be shutting down for maintenance”: This will shut down the system at 6:00 PM, and display the specified message to all users.

Conclusion

In this article, we have explained how to use the Linux shutdown command, and provided some examples. The shutdown command can be used to shut down or reboot a Linux system, either immediately or at a specific time. It is a useful tool for system administrators.

Jaspreet Singh Ghuman

Jaspreet Singh Ghuman

Jassweb.com/

Passionate Professional Blogger, Freelancer, WordPress Enthusiast, Digital Marketer, Web Developer, Server Operator, Networking Expert. Empowering online presence with diverse skills.

jassweb logo

Jassweb always keeps its services up-to-date with the latest trends in the market, providing its customers all over the world with high-end and easily extensible internet, intranet, and extranet products.

GSTIN is 03EGRPS4248R1ZD.

Contact
Jassweb, Rai Chak, Punjab, India. 143518
Item added to cart.
0 items - 0.00