Loading...

Lab 47: System Maintenance Commands

Perform late-night maintenance safely by scheduling shutdowns, notifying users, canceling pending power events, and executing clean reboots. Practice the modern and legacy command paths that you still see in real environments.

boot services troubleshooting

Scenario

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.

Operator context

Production maintenance is about clear communication and predictable system state changes. The goal is to minimize surprises: warn users, verify intent, and use the least disruptive command that accomplishes the operation.

Objective

  • Schedule a shutdown with a user-visible warning.
  • Cancel a scheduled shutdown safely.
  • Reboot immediately using standard tooling.
  • Simulate runlevel-based reboot behavior using init .
  • Understand the difference between halt and poweroff scheduling.

What You’ll Practice

  • Scheduling system power events with shutdown .
  • Canceling scheduled shutdown windows with shutdown -c .
  • Performing immediate reboots with reboot .
  • Legacy runlevel reboot semantics using init 6 .
  • Halting vs powering off the host using halt and shutdown -P .
  • Reading broadcast intent and understanding what users see.

Walkthrough

Step 1 : Alert users that the system will shut down in 15 minutes.
Command
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 clear change notice so people can save work and exit cleanly.

Broadcast message from root@lpic-lab47 (pts/0) (Tue Jul 22 01:15):
  The system is going down for maintenance in 15 minutes!
Shutdown scheduled for Tue 2025-07-22 01:15:00 UTC; use 'shutdown -c' to cancel.
Step 2 : Cancel the scheduled shutdown.
Command
sudo shutdown -c

Requirements change. This cancels the pending shutdown and notifies users. If you schedule by mistake, cancel immediately to avoid accidental downtime.

Broadcast message from root@lpic-lab47 (pts/0) (Tue Jul 22 01:04):
  Shutdown cancelled.
Planned shutdown has been cancelled.
Step 3 : Immediately reboot the system after applying updates.
Command
sudo reboot

This triggers a clean reboot sequence. The system will broadcast a reboot notice and begin shutting down services. Use this after patching when you need a kernel or service restart that cannot be done safely in-place.

Broadcast message from root@lpic-lab47 (pts/0):
  The system is going down for reboot NOW!
Step 4 : Simulate using init to change to runlevel 6 (reboot).
Command
sudo init 6

You still see this in legacy documentation and older admin habits. Runlevel 6 traditionally maps to reboot. On systemd systems, this typically transitions into the equivalent reboot target behavior.

init: Switching to runlevel: 6
Rebooting...
Step 5 : Halt the system immediately (simulate emergency stop).
Command
sudo halt

Halting stops the system. Depending on configuration and platform, it may not cut power. Treat this as an emergency-style operation and understand what your environment does.

The system is going down NOW!
System halted.
Step 6 : Power off the system after a 1-minute warning.
Command
sudo shutdown -P +1

This schedules a shutdown with power-off 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@lpic-lab47 (pts/0) (Tue Jul 22 01:16):
  The system will power off in 1 minute!
Shutdown scheduled for Tue 2025-07-22 01:17:00 UTC; use 'shutdown -c' to cancel.

Reference

  • shutdown +<minutes> : Schedules a shutdown and broadcasts a warning to users.
  • shutdown -c : Cancels a scheduled shutdown (also broadcasts cancellation).
  • reboot : Reboots the system using a clean shutdown/restart sequence.
  • init 6 : Legacy runlevel-based reboot command (runlevel 6 historically means reboot).
  • halt : Stops the system; power-off behavior may vary by configuration/platform.
  • shutdown -P +1 : Schedules a shutdown with power-off intent after a delay.
    • -P : Requests power-off after shutdown.