shutdown command in Linux with Examples

27 May, 2019
The shutdown command in Linux is used to shutdown the system in a safe way. You can shutdown the machine immediately, or schedule a shutdown using 24 hour format.It brings the system down in a secure way. When the shutdown is initiated, all logged-in users and processes are notified that the system is going down, and no further logins are allowed.Only root user can execute shutdown command.
Syntax of shutdown Command
shutdown [OPTIONS] [TIME] [MESSAGE]

options – Shutdown options such as halt, power-off (the default option) or reboot the system.
time – The time argument specifies when to perform the shutdown process.
message – The message argument specifies a message which will be broadcast to all users.
Options-r : Requests that the system be rebooted after it has been brought down.-h : Requests that the system be either halted or powered off after it has been brought down, with the choice as to which left up to the system.-H : Requests that the system be halted after it has been brought down.-P : Requests that the system be powered off after it has been brought down.-c : Cancels a running shutdown. TIME is not specified with this option, the first argument is MESSAGE.-k : Only send out the warning messages and disable logins, do not actually bring the system down.
How to use shutdownIn it’s simplest form when used without any argument, shutdown will power off the machine.
sudo shutdown

How to shutdown the system at a specified timeThe time argument can have two different formats. It can be an absolute time in the format hh:mm and relative time in the format +m where m is the number of minutes from now.
The following example will schedule a system shutdown at 05 A.M:
sudo shutdown 05:00

The following example will schedule a system shutdown in 20 minutes from now:
sudo shutdown +20
How to shutdown the system immediatelyTo shutdown your system immediately you can use +0 or its alias now:
sudo shutdown now

How to broadcast a custom messageThe following command will shut down the system in 10 minutes from now and notify the users with message “System upgrade”:
sudo shutdown +10 "System upgrade"

It is important to mention that when specifying a custom wall message you must specify a time argument too.
How to halt your systemThis can be achieved using the -H option.
shutdown -H

Halting means stopping all CPUs and powering off also makes sure the main power is disconnected.
How to make shutdown power-off machineAlthough this is by default, you can still use the -P option to explicitly specify that you want shutdown to power off the system.
shutdown -P

How to reboot using shutdownFor reboot, the option is -r.
shutdown -r

You can also specify a time argument and a custom message:
shutdown -r +5 "Updating Your System"

The command above will reboot the system after 5 minutes and broadcast Updating Your System”How to cancel a scheduled shutdownIf you have scheduled a shutdown and you want to cancel it you can use the -c argument:
sudo shutdown -c

When canceling a scheduled shutdown, you cannot specify a time argument, but you can still broadcast a message that will be sent to all users.
sudo shutdown -c "Canceling the reboot"

linux-command
Linux-system-commands
Picked
Linux-Unix
Writing code in comment?
Please use ide.geeksforgeeks.org,
generate link and share the link here.
Docker - COPY Instruction
scp command in Linux with Examples
chown command in Linux with Examples
SED command in Linux | Set 2
mv command in Linux with examples
chmod command in Linux with examples
nohup Command in Linux with Examples
Introduction to Linux Operating System
Basic Operators in Shell Scripting
Array Basics in Shell Scripting | Set 1