Linux 关机命令 All In One
Linux 关机命令 All In One
shutdown & poweroff
shutdown
$ man shutdown
$ man shutdown > ./Desktop/man-docs/shutdown.md
$ man shutdown
$ man shutdown > ./Desktop/man-docs/shutdown.md
pi@raspberrypi:~ $ cat ./Desktop/man-docs/shutdown.md
SHUTDOWN(8) shutdown SHUTDOWN(8)
NAME
shutdown - Halt, power-off or reboot the machine
SYNOPSIS
shutdown [OPTIONS...] [TIME] [WALL...]
DESCRIPTION
shutdown may be used to halt, power-off or reboot the machine.
The first argument may be a time string (which is usually "now"). Optionally, this may be followed by a wall
message to be sent to all logged-in users before going down.
The time string may either be in the format "hh:mm" for hour/minutes specifying the time to execute the
shutdown at, specified in 24h clock format. Alternatively it may be in the syntax "+m" referring to the
specified number of minutes m from now. "now" is an alias for "+0", i.e. for triggering an immediate
shutdown. If no time argument is specified, "+1" is implied.
Note that to specify a wall message you must specify a time argument, too.
If the time argument is used, 5 minutes before the system goes down the /run/nologin file is created to
ensure that further logins shall not be allowed.
OPTIONS
The following options are understood:
--help
Print a short help text and exit.
-H, --halt
Halt the machine.
-P, --poweroff
Power-off the machine (the default).
-r, --reboot
Reboot the machine.
-h
Equivalent to --poweroff, unless --halt is specified.
-k
Do not halt, power-off, reboot, just write wall message.
--no-wall
Do not send wall message before halt, power-off, reboot.
-c
Cancel a pending shutdown. This may be used to cancel the effect of an invocation of shutdown with a time
argument that is not "+0" or "now".
EXIT STATUS
On success, 0 is returned, a non-zero failure code otherwise.
SEE ALSO
systemd(1), systemctl(1), halt(8), wall(1)
systemd 247 SHUTDOWN(8)
pi@raspberrypi:~ $
poweroff
$ man poweroff
$ man poweroff > ./Desktop/man-docs/poweroff.md
$ man poweroff
$ man poweroff > ./Desktop/man-docs/poweroff.md
pi@raspberrypi:~ $ cat ./Desktop/man-docs/poweroff.md
HALT(8) halt HALT(8)
NAME
halt, poweroff, reboot - Halt, power-off or reboot the machine
SYNOPSIS
halt [OPTIONS...]
poweroff [OPTIONS...]
reboot [OPTIONS...]
DESCRIPTION
halt, poweroff, reboot may be used to halt, power-off, or reboot the machine. All three commands take the
same options.
OPTIONS
The following options are understood:
--help
Print a short help text and exit.
--halt
Halt the machine, regardless of which one of the three commands is invoked.
-p, --poweroff
Power-off the machine, regardless of which one of the three commands is invoked.
--reboot
Reboot the machine, regardless of which one of the three commands is invoked.
-f, --force
Force immediate halt, power-off, or reboot. When specified once, this results in an immediate but clean
shutdown by the system manager. When specified twice, this results in an immediate shutdown without
contacting the system manager. See the description of --force in systemctl(1) for more details.
-w, --wtmp-only
Only write wtmp shutdown entry, do not actually halt, power-off, reboot.
-d, --no-wtmp
Do not write wtmp shutdown entry.
-n, --no-sync
Don't sync hard disks/storage media before halt, power-off, reboot.
--no-wall
Do not send wall message before halt, power-off, reboot.
EXIT STATUS
On success, 0 is returned, a non-zero failure code otherwise.
NOTES
These commands are implemented in a way that preserves basic compatibility with the original SysV commands.
systemctl(1) verbs halt, poweroff, reboot provide the same functionality with some additional features.
Note that on many SysV systems halt used to be synonymous to poweroff, i.e. both commands would equally
result in powering the machine off. systemd is more accurate here, and halt results in halting the machine
only (leaving power on), and poweroff is required to actually power it off.
SEE ALSO
systemd(1), systemctl(1), shutdown(8), wall(1)
systemd 247 HALT(8)
pi@raspberrypi:~ $
Raspberry Pi
关机命令
# 关闭电源
$ sudo poweroff
# 立即关机
$ sudo shutdown -h now
# 等价于
$ sudo shutdown -h +0
# 立即重启
$ sudo shutdown -r now
# 等价于
$ sudo shutdown -r +0
# 取消关机
$ sudo shutdown -c
-h === host
-h === halt
停止
-r === reboot
重新启动
-c === cancel
取消
demos
# shutdown [OPTIONS] [TIME] [MESSAGE]
# 3 分钟后自动关机,并且广播提醒所有用户 🔔 ⚠️
$ sudo shutdown -h +3 "🔔 3 分钟后关机, 请提前做好文件保存!"
# 等价于 `hh:mm`
$ sudo shutdown -h 00:03 "🔔 3 分钟后关机, 请提前做好文件保存!"
# 3 分钟后自动重启,并且广播提醒所有用户 🔔 ⚠️
$ sudo shutdown -r +3 "🔔 3 分钟后重启, 请提前做好文件保存!"
# 取消自动关机,并且广播提醒所有用户 🔔 ⚠️
$ sudo shutdown -c "Canceling the reboot"
pi@raspberrypi:~/Desktop $ shutdown --help
shutdown [OPTIONS...] [TIME] [WALL...]
Shut down the system.
Options:
--help Show this help
-H --halt Halt the machine # ✅ halt
-P --poweroff Power-off the machine
-r --reboot Reboot the machine
-h Equivalent to --poweroff, overridden by --halt # -h 等价于 --poweroff ✅
-k Don't halt/power-off/reboot, just send warnings
--no-wall Don't send wall message before halt/power-off/reboot
-c Cancel a pending shutdown
See the shutdown(8) man page for details.
$ man shutdown
# 等待⌛️一分钟后,不取消就立刻关机 ✅
$ sudo shutdown -H
$ ssh pi@raspberrypi.local
macOS
关机命令 shutdown
$ sudo shutdown -h
# usage: shutdown [-] [-h [-u] [-n] | -r [-n] | -s | -k] time [warning-message ...]
# macOS
$ man shutdown
# macOS
$ man shutdown
SHUTDOWN(8) System Manager's Manual SHUTDOWN(8)
NAME
shutdown – close down the system at a given time
SYNOPSIS
shutdown [-] [-h [-u] | -r | -s | -k] [-o [-n]] time [warning-message ...]
DESCRIPTION
The shutdown utility provides an automated shutdown procedure for super-users to nicely notify users when the system is shutting down, saving them from system administrators, hackers, and gurus, who would otherwise not bother with such
niceties.
The following options are available:
-h The system is halted at the specified time. # ✅ halt
-k Kick everybody off. The -k option does not actually halt the system, but leaves the system multi-user with logins disabled (for all but super-user).
-n If the -o is specified, prevent the file system cache from being flushed by passing -n option to halt(8) or reboot(8). This option should probably not be used.
-o If -h or -r is specified, shutdown will execute halt(8) or reboot(8) instead of sending a signal to launchd(8).
-r The system is rebooted at the specified time.
-s The system is put to sleep at the specified time.
-u The system is halted up until the point of removing system power, but waits before removing power for 5 minutes so that an external UPS (uninterruptible power supply) can forcibly remove power. This simulates a dirty shutdown to
permit a later automatic power on. macOS uses this mode automatically with supported UPSs in emergency shutdowns.
time Time is the time at which shutdown will bring the system down and may be the word now (indicating an immediate shutdown) or specify a future time in one of two formats: +number, or yymmddhhmm, where the year, month, and day may
be defaulted to the current system values. The first form brings the system down in number minutes and the second at the absolute time specified.
warning-message
Any other arguments comprise the warning message that is broadcast to users currently logged into the system.
- If ‘-’ is supplied as an option, the warning message is read from the standard input.
At intervals, becoming more frequent as apocalypse approaches and starting at ten hours before shutdown, warning messages are displayed on the terminals of all users logged in.
At shutdown time a message is written to the system log, containing the time of shutdown, the person who initiated the shutdown and the reason. Corresponding signal is then sent to launchd(8) to respectively halt, reboot or bring the
system down to single-user state (depending on the above options).
A scheduled shutdown can be canceled by killing the shutdown process (a SIGTERM should suffice).
SIGTERM TO SIGKILL INTERVAL
Upon shutdown, all running processes are sent a SIGTERM followed by a SIGKILL. The SIGKILL will follow the SIGTERM by an intentionally indeterminate period of time. Programs are expected to take only enough time to flush all dirty data
and exit. Developers are encouraged to file a bug with the OS vendor, should they encounter an issue with this functionality.
SEE ALSO
kill(1), login(1), wall(1), halt(8), launchd(8), reboot(8)
BACKWARD COMPATIBILITY
The hours and minutes in the second time format may be separated by a colon (``:'') for backward compatibility.
HISTORY
The shutdown utility appeared in 4.0BSD.
macOS 13.1 December 11, 1998
How To Shutdown Linux Using Command Line
$ su -
# or
$ sudo -s
# root password
$ shutdown -h now
# OR
$ shutdown -h +0
$ sudo systemctl poweroff
#
$ sudo poweroff

Reboot Linux system command syntax
The syntax is:
shutdown -h time "message"
Where,
-h
: Poweroff the system.
time
: When to shutdown. You can poweroff immediately or after 2 minutes.
It can be an absolute time in the format hh:mm
, in which hh is the hour (1 or 2 digits) and mm is the minute of the hour (in two digits).
Second, it can be in the format +m
, in which m is the number of minutes
to wait.
The word now
is an alias for +0
.
message
: Send warning message to send to all users.
macOS shutdown
$ man shutdown
# OR
$ man 8 shutdown
supported UPSs in emergency shutdowns.
time Time is the time at which shutdown will bring the system down and may be the
word now (indicating an immediate shutdown) or specify a future time in one
of two formats: +number, or yymmddhhmm, where the year, month, and day may
be defaulted to the current system values. The first form brings the system
down in number minutes and the second at the absolute time specified.
warning-message
Any other arguments comprise the warning message that is broadcast to users
currently logged into the system.
- If ‘-’ is supplied as an option, the warning message is read from the
standard input.
At intervals, becoming more frequent as apocalypse approaches and starting at ten
hours before shutdown, warning messages are displayed on the terminals of all users
logged in.
At shutdown time a message is written to the system log, containing the time of
shutdown, the person who initiated the shutdown and the reason. Corresponding
signal is then sent to launchd(8) to respectively halt, reboot or bring the system
down to single-user state (depending on the above options).
A scheduled shutdown can be canceled by killing the shutdown process (a SIGTERM
should suffice).
SIGTERM TO SIGKILL INTERVAL
Upon shutdown, all running processes are sent a SIGTERM followed by a SIGKILL. The
SIGKILL will follow the SIGTERM by an intentionally indeterminate period of time.
Programs are expected to take only enough time to flush all dirty data and exit.
Developers are encouraged to file a bug with the OS vendor, should they encounter an
issue with this functionality.
SEE ALSO
kill(1), login(1), wall(1), halt(8), launchd(8), reboot(8)
BACKWARD COMPATIBILITY
The hours and minutes in the second time format may be separated by a colon (``:'')
for backward compatibility.
HISTORY
The shutdown utility appeared in 4.0BSD.
macOS 12.3 December 11, 1998 macOS 12.3
$ last shutdown
shutdown ~ Fri Jul 1 22:10
shutdown ~ Thu Jun 30 10:03
shutdown ~ Fri Jun 24 22:10
shutdown ~ Wed Jun 22 16:32
shutdown ~ Fri Jun 10 22:10
shutdown ~ Fri May 20 22:10
shutdown ~ Fri Apr 22 22:10
shutdown ~ Tue Apr 12 02:45
wtmp begins Wed Mar 30 07:58
demos
refs
https://www.cyberciti.biz/faq/howto-shutdown-linux/
https://linuxize.com/post/linux-shutdown-command/
LEMP
PHP
https://www.cnblogs.com/xgqfrms/p/5361895.html
©xgqfrms 2012-2025
www.cnblogs.com/xgqfrms 发布文章使用:只允许注册用户才可以访问!
原创文章,版权所有©️xgqfrms, 禁止转载 🈲️,侵权必究⚠️!
本文首发于博客园,作者:xgqfrms,原文链接:https://www.cnblogs.com/xgqfrms/p/16478039.html
未经授权禁止转载,违者必究!
【推荐】国内首个AI IDE,深度理解中文开发场景,立即下载体验Trae
【推荐】编程新体验,更懂你的AI,立即体验豆包MarsCode编程助手
【推荐】抖音旗下AI助手豆包,你的智能百科全书,全免费不限次数
【推荐】轻量又高性能的 SSH 工具 IShell:AI 加持,快人一步
· 物流快递公司核心技术能力-地址解析分单基础技术分享
· .NET 10首个预览版发布:重大改进与新特性概览!
· 单线程的Redis速度为什么快?
· 展开说说关于C#中ORM框架的用法!
· Pantheons:用 TypeScript 打造主流大模型对话的一站式集成库
2021-07-14 js disabled debugger All In One
2021-07-14 css nth-of-type All In One
2021-07-14 mac 外接显示器设置旋转方向 All In One
2020-07-14 测试金字塔
2020-07-14 frontends tools
2020-07-14 微前端 & 微前端实践 & 微前端教程
2020-07-14 支付宝小程序模版