Perform maintenance safely by scheduling shutdowns with user warnings, canceling pending power events, and executing clean reboots. Practice the modern and legacy command paths you still encounter in production environments.
You are performing late-night maintenance on a production server. Updates have been applied, users are still logged in, and you must schedule a shutdown window, cancel it when required, then reboot cleanly. You also need to understand legacy runlevel reboot behavior and the difference between halting and powering off.
Maintenance is about communication and predictable state changes. Warn users, verify intent, and use the least disruptive operation that achieves the required outcome.
init 6
and understand what it maps to.
init 6
) and how they map on modern systems.
sudo shutdown +15
This schedules a shutdown in 15 minutes and broadcasts a warning to logged-in users. In real maintenance windows, you pair this with a change notice so users can save work and exit cleanly.
Broadcast message from root@host (pts/0) (Tue Jul 22 01:00):
The system is going down for maintenance in 15 minutes!
sudo shutdown -c
This cancels the pending shutdown and notifies users. If you scheduled the wrong window, cancel immediately to prevent accidental downtime.
Broadcast message from root@host (pts/0) (Tue Jul 22 01:01):
Shutdown cancelled.
sudo reboot
This triggers a clean reboot sequence. The system will stop services, terminate sessions, and restart. Use this when you need a kernel reboot or when an in-place restart is not operationally safe.
Broadcast message from root@host (pts/0):
The system is going down for reboot NOW!
sudo init 6
You still see this in older runbooks and documentation. Runlevel 6 traditionally maps to reboot. On systemd systems, this typically transitions into the equivalent reboot target behavior.
init: Switching to runlevel: 6
Rebooting...
Halt behavior varies. In some environments it may stop the OS without cutting power. Do not assume the machine is safe to service physically unless you have confirmed power state.
sudo halt
Halting stops the system. Treat this as a controlled operation and understand how your platform maps halt versus poweroff.
The system is going down NOW!
System halted.
sudo shutdown -P +1
This schedules a shutdown with explicit poweroff intent. The warning gives users a final moment to stop work, and the system will proceed to stop services and power down the host.
Broadcast message from root@host (pts/0) (Tue Jul 22 01:02):
The system will power off in 1 minute!
Shutdown scheduled; use 'shutdown -c' to cancel.
Scheduling power events requires root privileges. Use
sudo
and confirm your account has the required policy.
There may be nothing pending, or the event may have been scheduled by another tool (systemd timers, orchestration, or a provider control plane). Confirm what actually queued the power event before assuming cancellation failed.
On modern systems,
init
often forwards to systemd compatibility behavior. Treat it
as a legacy interface and prefer
reboot
or
shutdown
in new runbooks.
Halt can stop the OS without cutting power. If you require
poweroff, use
shutdown -P
and confirm the platform behavior (physical host, VM,
cloud instance).
This lab performs state-changing operations. Your cleanup is to ensure no unintended shutdown is queued, communicate the final maintenance outcome, and confirm services are healthy after the reboot.
sudo shutdown -c
# After reboot, validate the host is back and reachable:
uptime
who
No shutdown is pending, the system returns cleanly after the reboot, and users were warned and informed throughout the maintenance window.
shutdown +<minutes>
: Schedules a shutdown and broadcasts a warning to users.
+<minutes>
: Delay before the shutdown occurs.
shutdown -c
: Cancels a scheduled shutdown and broadcasts cancellation.
-c
: Cancel the pending shutdown.
reboot
: Reboots the system using a clean shutdown/restart sequence.
init 6
: Legacy runlevel reboot command (runlevel 6 historically maps to reboot).
halt
: Stops the system; power-off behavior may vary by environment.
shutdown -P +<minutes>
: Schedules a shutdown with poweroff intent after a delay.
-P
: Request poweroff after shutdown.