How to Safely Shut Down Linux with the poweroff Command
Learn how to use the Linux poweroff command to safely shut down the operating system, understand its logging behavior, explore available options such as -n, -w, -d, -i, -h, -f, and see practical examples and related commands for viewing shutdown logs.
poweroff: Shut Down the System
Function Description:
The poweroff command shuts down the computer operating system and cuts power. Use it when no users are logged in and all data is saved, and you need an immediate shutdown.
The shutdown record is written to the /var/log/wtmp log file.
Command Syntax:
poweroff [options]Option Meanings:
The meanings of the command options are as follows:
-n : Do not perform sync before shutting down.
-w : Do not actually shut down; only write to /var/log/wtmp.
-d : Do not write the shutdown operation to the /var/log/wtmp log file.
-i : Close all network interfaces before shutting down.
-h : Set all hardware to standby mode before shutting down.
-f : Force shutdown.
Example:
Shut down the computer operating system and cut power:
# poweroffAdditional Knowledge:
How to view the /var/log/wtmp log file in Linux:
last -f /var/log/wtmp // wtmp is a binary file; use the last command to viewEquivalent to executing:
lastSigned-in readers can open the original source through BestHub's protected redirect.
This article has been distilled and summarized from source material, then republished for learning and reference. If you believe it infringes your rights, please contactand we will review it promptly.
Open Source Linux
Focused on sharing Linux/Unix content, covering fundamentals, system development, network programming, automation/operations, cloud computing, and related professional knowledge.
How this landed with the community
Was this worth your time?
0 Comments
Thoughtful readers leave field notes, pushback, and hard-won operational detail here.
