Linux之关机、重启命令

shutdown

SHUTDOWN(8) BSD 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.

 -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. OS X 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 broad-
         cast 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 start-
 ing 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 inde-
terminate 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 func-
tionality.

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.

BSD December 11, 1998 BSD

halt/reboot

REBOOT(8) BSD System Manager’s Manual REBOOT(8)

NAME
halt, reboot – stopping and restarting the system

SYNOPSIS
halt [-lnqu]
reboot [-lnq]

DESCRIPTION
The halt and reboot utilities flush the file system cache to disk, send all running processes a SIGTERM
(and subsequently a SIGKILL) and, respectively, halt or restart the system. The action is logged,
including entering a shutdown record into the wtmp(5) file.

 When the system is halted with the halt command, the system is powered off.

 The options are as follows:

 -l      The halt or reboot is not recorded in the system log.  This option is intended for applications
         such as shutdown(8), that call reboot or halt and log this themselves.

 -n      The file system cache is not flushed.  This option should probably not be used.

 -q      The system is halted or restarted quickly and ungracefully, and only the flushing of the file
         system cache is performed (if the -n option is not specified).  This option should probably not
         be used.

 -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. OS X uses this mode auto-
         matically with supported UPSs in emergency shutdowns.

 Normally, the shutdown(8) utility is used when the system needs to be halted or restarted, giving users
 advance warning of their impending doom and cleanly terminating specific programs.

示例:

shutdown -h 15 #15分钟后关机
shutdown -h now #立即关机,同halt
shutdown -h yymmddhhmm #按年月日时分格式替换,到该时刻关机
shutdown -r +15 #15分钟后重启
shutdown -r now #立即重启,同reboot
reboot #立即重启
halt #立即关机

【提示】如果对某个命令不清楚,可以使用man命令查看,如

man shutdown

【补充】如果忘记了root密码,可以在进入开机界面时快速按下向下键,选中第一个选项并根据提示按e进入编辑状态,修改 ro 为 rw init=/sysroot/bin/bash,根据提示同时按Ctrl+x进入急救模式
根据如下命令进行后续操作即可完成密码修改

chroot /sysroot/
passwd #修改密码
touch /.autorelabel

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值