The shutdown
command is used to safely turn off or restart a Linux system. It allows users to schedule shutdowns, notify logged-in users, and specify the reason for the shutdown.
The basic syntax of the shutdown
command is as follows:
shutdown [options] [time] [message]
-h
or --halt
: Halts the system after shutdown.-r
or --reboot
: Reboots the system after shutdown.-P
or --poweroff
: Powers off the machine after shutdown.-c
: Cancels a scheduled shutdown.time
: Specifies when to shut down (e.g., now
, +5
for five minutes later, or a specific time like 23:00
).message
: An optional message to display to users before shutdown.shutdown now
shutdown +10
shutdown -r now
shutdown 23:30
shutdown -c
shutdown +5 "System will shut down in 5 minutes for maintenance."
-c
option to cancel a shutdown if you change your mind.shutdown -h
for a complete halt or shutdown -r
for a reboot, depending on your needs.