Linux系统关机命令详解

技 经 济市 场
L i n u x系统关机命令详解
陈帮 鹏 , 张 欣
( 张 家 口职 业技 术 学院 , 河北 张 家 口 0 7 5 0 0 0 )
摘 要 : 随着 I n t e r n e t 的迅 猛 发 展 , 计算机在 我国迅速普及。 而 L 1 n u x操 作 系 统做 为 P C 的 主 流 操 作 系 统 之 一也 进 入 了我 们 的 视 野。 想 妻 轻 松 自如 的使 用 L 1 n u x系 统就 必 须 学 习 L i n u x命 令 。 本 文 从 系 统 运 行 的角 度 着 重分 析 讲 解 了 L 1 n u x系 统 的 关 机 命 令 , 以便 用户能够正确使用 L 1 n u X操 作 系 统 。 关键词 : L 1 n L I X; 操 作 系统 ; 运行级别 ; 命 令
主要 参 数 :

h : 关 机 后关 闭 电 源 。 t : 在系统运行级别改变以前 , 通知 i n i t 系统 关 机 时 间 。

满足网络对操作系统多用户 、 多任 务 、 多线程的要求 。 它 脱 胎 于
U N I X, 所 以就 继 承 了 U N I X大部分特性 。同时 L i n u x 本 身 拥 有
写、 文 件 目录操 作 、 进程管理 等。因此 , 在L i n u x系 统 环 境 下 工
作就离不开 L i n u x命 令 。要 想 从 真 正 意 义 上 精 通 L i n u x系统 操


作, 我 们必须 从 L i n u x基 础 命 令 开 始 学 习 , 通 过 学 习这 些 基 础 的L i n u x 命 令 达 到 更 好 的帮 助 我 们 操 作 L i n u x系 统 。
学习 L i n u x系统 环 境 下 的关 机 命 令 首 先 就 要 先 了解 L i n u x 的运行级别 , L i n u x系 统 有 7个 运 行 级 别 :
带 时 间参 数 , 但 是 可 以输 人 信 息 , 而 输 入 的信 息 就 会 送 达 每位
登录者。

F: 强迫系统在重启计算机时进行 f s c k 。
统。
作用 : 系统 关 闭命 令 。只 有 超 级 用 户 能 使 用 格式 : h a l t[ 一 n ][ 一 i ][ 一 f l[ 一 W ]卜p ][ 一 d ]
主 要 参 数

# 6系统 正 常 关 闭 并 重 启 , 不能设为默认运行级 别 , 否 则 不
能正常启动 。 ・
与 Wi n d o w s 不同, 在 其运行时后 台运行着许 多进程 , 当 关 机 时
这些 进程 都要 把数 据 回 写 到 硬 盘 中 。 所 以切 断 电 源 关 机 就 可 能 会 导 致 进 程 的数 据 丢 失 , 使 系统 处 于 崩 溃 的边 缘 , 更 甚 者 会 直 接损坏硬盘。 与s h u t d o w n命 令 作 用 相 似 的命 令 还 有 h a l t 。

k : 只 是 给 每 位 登 录用 户 送 出关 机 警 告 信 号 , 但 并 不 真 正
i : 关闭操作系统时显示系统信息 。 t i m e : 设定关机前的时间 。 c : 取 消 当 前 正 在 执 行 的关 机操 作 程 序 。因 此 这 个 选 项 不
关机 。

非 常 丰 富 的命 令 , 可以帮助用户完 成很多 系统工作 , 如 磁 盘 读
L i n u x 是 一 种 网络 操 作 系统 ,所 以在 其 中 包 含 有 许 多 服 务 器 脚 本 程 序 ,它 们 存 储 于 目 录/ e t c / r c . d / i n i t . d 中 , 我 们 统 称 为
n :只 有 在 使 用 f s c k程 序 修 补 过 根 分 区 之 后 才 能用 到 这

m:把 系 统 改 为 单 用 户 模 式 。
} } o系 统 停 机 。 这 个 千 万 不 能 设 置 为 系 统 默认 的 运 行 级 别 ,
如设为系统默认运行级别 , 系统 就不 能 正 常启 动 , 机器关闭。
# l单 用 户 工 作 状 态 , 这是 r o o t 权限, 用 于 系统维 护 , 禁 止 远程登陆 。 : I } 2多用 户 状 态 , 没有 N F S支 已成 为 当今 世 界 使 用 最 多 的一 种 U N I X 类 操 作 系 统 ,并 且 使 用 人 数 还 在 随 着 计 算 机 的 普 及 而 迅 猛 增 长 。
L i n u x 本 身 是 构 成 自由软 件 协 议 基 础 的一 种 操 作 系 统 .它 完 全
在这 里我们需 要说 明的是 L i n u x 操 作 系 统 需 要 安 全 的 关
闭, 使用 s h u t d o w n命 令 就 可 以安 全 地 关 闭 L i n u x系 统 。但 在 实
际 中 ,有 些 新 人 会 用 直 接 切 断 电源 的方 法 关 闭 L i n u x系 统 , 长 期使用 这种方法对 L i n u x系 统 来 讲 是 十分 危 险 的 。 因 为 L i n u x
个参数 , 主要 作 用 就 是 防 止 内 核用 修 补 之 前 的超 级块 覆 盖 已修
补 过 的超 级 块 。
h a l t
# 3完 整 的 多 用 户 模 式 , 有N F S , 登 陆 后 进 入 控 制 台命 令 行
模式 。
# 4系 统 保 留一 般 不 用 ,在 一 些 特 殊 情 况 下 可 以用 它 来 做

些 事情 。
# 5 X1 1控 制 台 , 登 陆 后 进 入 图形 G U I 模式 , X Wi n d o w 系
合集下载

linuxshutdown命令以及参数详解

linuxshutdown命令以及参数详解

linuxshutdown命令以及参数详解
在说shutdown命令之前
先说⼀下sync命令:
sync:将内存中尚未写⼊硬盘的数据写⼊硬盘
因为linux为了保证数据读写速度,把常⽤的数据放在内存中,不会⽴即写⼊硬盘,如果有不当关机,这些数据就会丢失
所以在执⾏shutdown、reboot之类的命令之前,应当多执⾏⼏次sync命令来保证数据不丢失(虽然shutdown和reboot命令执⾏之后会⾃动执⾏sync,但是还是⼩⼼⼀些为好)
shutdown命令:
可搭配参数:
-t :后⾯跟数字,也就是“⼏秒之后关机”的意思,单位是秒(除了此指令后⾯的数字单位是秒,其他指令后⾯数字单位都是分钟,)-k :不是真正的关机,但是会向当前所有在线⽤户发送指令后⾯跟着的语句“语句⽤单引号包裹”(其他指令后⾯默认可以跟随语句——不过我试了⼀下好像没⽤?⽹上也没有找到资料,等接触到了再来更新~)
-r :将系统服务停⽌之后重启机器
-h :关掉系统服务之后⽴即关机(后⾯可以跟上数字,单位是分钟,也可以跟指令执⾏时刻,格式为xx:xx)
-n :不经过init程序,直接通过shutdown命令关机(此处对于init程序理解不是很深,需要重新学习)
-f :关机并且开机之后强制略过fsck磁盘检查
-F :系统重启之后,强制进⾏fsck磁盘检查
-c :取消已经在进⾏的shutdown命令内容(撤销关机——但是对于t参数为0或者now的关机指令不起作⽤)
常⽤的就是"sync;sync; sudo shutdown -h now"
也就是将内存内数据写⼊硬盘之后⽴即关机的意思。

Linux终端中的系统关机和重启命令

Linux终端中的系统关机和重启命令

Linux终端中的系统关机和重启命令Linux作为一种开源的操作系统,具有很高的灵活性和自定义性。

在使用Linux终端时,系统关机和重启是经常涉及到的操作。

本文将介绍Linux终端中常用的系统关机和重启命令,供用户参考和使用。

1. 关机命令在Linux终端中,通过使用特定的关机命令可以实现系统的安全关机,保证数据的完整性,避免出现数据丢失或损坏的情况。

下面是常用的关机命令及其用法:1.1. shutdown命令shutdown命令可实现系统的关机操作,并向所有登录用户发送关机通知。

命令格式如下:```shutdown [选项] 时间 [警告信息]```常用选项:- -r: 关机后立即重启系统- -h: 关机后不重启系统- -c: 取消已经设置的关机操作- -t seconds: 设置关机前的等待时间(以秒为单位)示例:```shutdown -h now # 立即关机shutdown -h +10 # 10分钟后关机shutdown -r 20:00 # 指定时间关机并重启shutdown -c # 取消当前关机操作```1.2. poweroff命令poweroff命令负责关闭电源,可以用来执行硬件完全关机,对电源断电。

命令格式如下:```poweroff```示例:```poweroff```1.3. halt命令halt命令用于停止系统运行,并使计算机进入停止状态。

命令格式如下:```halt```示例:```halt```1.4. init命令init命令用于改变系统的运行等级,其中运行等级0为关机状态,通常用init命令实现关机操作。

命令格式如下:```init [运行等级]```示例:```init 0```2. 重启命令有时候需要重启系统以应用修改或解决一些问题。

在Linux终端中,可以使用以下命令实现系统的重启:2.1. reboot命令reboot命令用于重启系统,它会关闭所有正在运行的进程,并重新引导计算机。

Linux终端中的系统启动和关机命令

Linux终端中的系统启动和关机命令

Linux终端中的系统启动和关机命令Linux作为一个开源的操作系统,具有强大的灵活性和自定义性。

在Linux终端中,我们可以使用一些命令来控制系统的启动和关机。

本文将详细介绍一些常用的系统启动和关机命令,并探讨它们的功能和使用方法。

一、系统启动命令1. rebootreboot命令用于重新启动系统。

在终端中输入reboot后,系统将会立即重启。

这个命令非常有用,尤其是在需要迅速重启系统的情况下,如在安装软件或更新内核后。

2. shutdownshutdown命令用于正常关机系统。

默认情况下,输入shutdown命令后系统将在一分钟后执行关机操作。

如果需要设置关机时间,可以使用“shutdown -h now”命令来立即关机,或者使用“shutdown -h +分钟数”命令来设置延迟关机的时间。

除了关机命令,shutdown还可以用于重启系统。

例如,使用“shutdown -r now”命令将会立即重启系统。

3. initinit命令是Linux系统的初始化命令,用于切换系统的运行级别。

运行级别是电脑中一种特定的工作状态,对应着一组特定的功能服务。

Linux系统共有七个运行级别,分别是0-6。

其中,0表示关机,6表示重启。

要切换运行级别,可以使用“init 数字”命令进行操作。

例如,“init 3”将将系统切换到文本模式,而“init 5”则进入图形模式。

二、系统关机命令1. halthalt命令用于立即关机系统。

它会发送一个信号给内核,告诉系统立即关闭。

输入“halt”命令后,系统将会停止所有进程并关机。

2. poweroffpoweroff命令用于正常关机系统。

它会先发送一个信号给所有运行的进程,告诉它们系统即将关机。

这个命令会在关机前允许进程的保存和关闭操作,确保数据的完整性。

3. init在上一节中我们已经介绍了init命令的用途。

当我们使用“init 0”或“init 6”命令时,系统将会执行关机或重启操作。

linux虚拟机关机、重启命令

linux虚拟机关机、重启命令

linux虚拟机关机、重启命令linux虚拟机关机、重启命令2018-08-20 14:10:31 53806 收藏 101⼀.shutdown1.shutdown -h now :⽴即关机2.shutdown -h 10:53:到10:53关机3.shutdown -h +10 :10分钟后⾃动关机4.shutdown -r :重启(默认30秒)5.shutdown -r now :⽴即重启6.shutdown -r +30 :’The System Will Reboot 30 in Mins’:30分钟后重启并发送通知给其他在线⽤户7.shutdown -s -t 100 :延迟100秒关机8.shutdown -a :取消上⾯的关机、重启⼆、reboot1.reboor :重启,相当于shutdown -r now2.reboot -d :重新启动时不把数据写⼊记录⽂件 /var/tmp/wtmp3.reboot -f :强制重新开机4.reboot -h:在系统关机之前,将所有的硬盘处于待机模式下5.reboot -i :关闭⽹络设置之后再重新启动系统6.reboot -n :保存数据后重启三、halt1.halt :关机2.halt -d :关闭系统,不把记录写到/var/log/wtmp⽂件⾥3.halt -p :关机并关闭电源4.halt -f :强制关机四、init1.init 0 :关机2.0-6:表⽰系统运⾏的7个级别0:关机级别1:单⽤户级别,运⾏rc.sysinit和rc1.d⽬录下的脚本2:多⽤户,但系统不会启动NFS,字符模式3:多⽤户,字符模式,系统启动具有⽹络功能4:⽤户⾃定义级别5:图形界⾯模式6:重启级别五、poweroff1.poweroff :关机并关闭电源2.poweroff -p:关机并关闭电源3.poweroff -f :强制关机4.poweroff -w:不是真正的关机,只是将数据写⼊到/var/log/wtmp⽂件⾥六、按Ctrl + Alt + Delete键—- 选择关机。

linux服务器重启指令

linux服务器重启指令

linux服务器重启指令⼀、Linux 的五个重启命令 在linux下⼀些常⽤的关机/重启命令有shutdown、halt、reboot、及init,它们都可以达到重启系统的⽬的⼆、五个重启命令的具体说明 1.shutdown shutdown命令安全地将系统关机。

有些⽤户会使⽤直接断掉电源的⽅式来关闭linux,这是⼗分危险的。

因为linux与windows不同,其后台运⾏着许多进程,所以强制关机可能会导致进程的数据丢失﹐使系统处于不稳定的状态﹐甚⾄在有的系统中会损坏硬件设备。

⽽在系统关机前使⽤shutdown命令﹐系统管理员会通知所有登录的⽤户系统将要关闭。

并且login指令会被冻结﹐即新的⽤户不能再登录。

直接关机或者延迟⼀定的时间才关机都是可能的﹐还可能重启。

这是由所有进程〔process〕都会收到系统所送达的信号〔signal〕 决定的。

这让像vi之类的程序有时间储存⽬前正在编辑的⽂档﹐⽽像处理邮件〔mail〕和新闻〔news〕的程序则可以正常地离开等等。

shutdown执⾏它的⼯作是送信号〔signal〕给init程序﹐要求它改变runlevel。

Runlevel 0被⽤来停机〔halt〕﹐runlevel 6是⽤来重新激活〔reboot〕系统﹐⽽runlevel 1则是被⽤来让系统进⼊管理⼯作可以进⾏的状态﹔这是预设的﹐假定没有-h也没有-r参数给shutdown。

要想了解在停机〔halt〕或者重新开机〔reboot〕过程中做了哪些动作﹐你可以在这个⽂件/etc/inittab⾥看到这些runlevels相关的资料。

shutdown 参数说明: [-t] 在改变到其它runlevel之前﹐告诉init多久以后关机。

[-r] 重启计算器。

[-k] 并不真正关机﹐只是送警告信号给 每位登录者〔login〕。

[-h] 关机后关闭电源〔halt〕。

[-n] 不⽤init﹐⽽是⾃⼰来关机。

linux虚拟机关机、重启命令

linux虚拟机关机、重启命令

linux虚拟机关机、重启命令linux虚拟机关机、重启命令⼀.shutdown1.shutdown -h now :⽴即关机2.shutdown -h 10:53:到10:53关机3.shutdown -h +10 :10分钟后⾃动关机4.shutdown -r :重启(默认30秒)5.shutdown -r now :⽴即重启6.shutdown -r +30 :’The System Will Reboot 30 in Mins’:30分钟后重启并发送通知给其他在线⽤户7.shutdown -s -t 100 :延迟100秒关机8.shutdown -a :取消上⾯的关机、重启⼆、reboot1.reboor :重启,相当于shutdown -r now2.reboot -d :重新启动时不把数据写⼊记录⽂件 /var/tmp/wtmp3.reboot -f :强制重新开机4.reboot -h:在系统关机之前,将所有的硬盘处于待机模式下5.reboot -i :关闭⽹络设置之后再重新启动系统6.reboot -n :保存数据后重启三、halt1.halt :关机2.halt -d :关闭系统,不把记录写到/var/log/wtmp⽂件⾥3.halt -p :关机并关闭电源4.halt -f :强制关机四、init1.init 0 :关机2.0-6:表⽰系统运⾏的7个级别0:关机级别1:单⽤户级别,运⾏rc.sysinit和rc1.d⽬录下的脚本2:多⽤户,但系统不会启动NFS,字符模式3:多⽤户,字符模式,系统启动具有⽹络功能4:⽤户⾃定义级别5:图形界⾯模式6:重启级别五、poweroff1.poweroff :关机并关闭电源2.poweroff -p:关机并关闭电源3.poweroff -f :强制关机4.poweroff -w:不是真正的关机,只是将数据写⼊到/var/log/wtmp⽂件⾥六、按Ctrl + Alt + Delete键—- 选择关机。

linux,halt指令参数及用法详解_linux halt指令


启。关于 init 可以长篇大论﹐这里就不再叙述。另外还有 telinit 命令
可以改变 init 的运行级别﹐比如﹐telinit -iS 可使系统进入单用户模
式﹐并且得不到使用 shutdown 时的信息和等待时间。
看了“linux halt 命令参数及用法详解”还想看:
第3页共3页
2.Linux 系统中重启命令如何使用
[-i] 关机〔或重启〕前﹐关掉所有的网络接口。
3.Linux 的重启命令有哪些 Linux 的重启命令教程
[-p] 该选项为缺省选项。就是关机时调用 poweroff。
4.centos 关机与重启命令详解
3.reboot
reboot 的工作过程差不多跟 halt 一样﹐不过它是引发主机重启﹐而
理邮件〔mail〕和新闻〔news〕的程序则可以正常地离开等等。
信息将会送到每位使用者。
shutdown 执行它的工作是送信号〔signal〕给 init 程序﹐要求它改
[-f] 在重启计算器〔reboot〕时忽略 fsck。
变 runlevel。Runlevel 0 被用来停机〔halt〕﹐runlevel 6 是用来重新
-f : 强迫关机,不呼叫 shutdown 这个指令
第1页共3页
本文格式为 Word 版,下载可任意编辑,页眉双击删除即可。
用户系统将要关闭。并且 login 指令会被冻结﹐即新的用户不能再登录。
ห้องสมุดไป่ตู้
[-n] 不用 init﹐而是自己来关机。不鼓励使用这个选项﹐而且该选
直接关机或者延迟一定的时间才关机都是可能的﹐还可能重
[-w] 并不是真正的重启或关机﹐只是写 wtmp〔/var/log/wtmp〕纪

Linux关机命令分析

Linux关机命令分析linux下有关关机重启的命令主要有:shutdown、reboot、halt、poweroff、telinit、init。

它们都可以达到关机或重启的目的,但是每个命令的工作流程并不一样。

它们都由软件包sysvinit生成,你可以从网上下载它的源码来分析各个命令的流程,同时,sysvinit也包含了与登陆等有关的命令。

下面分析sysvinit-2.86软件包的源码,同时参考它们的手册来对它们深入了解。

1、从Makefile可以知道,上面的命令并不都是互相独立的,poweroff、reboot是halt 的链接,telinit是init的链接。

ln -sf halt $(ROOT)/sbin/rebootln -sf halt $(ROOT)/sbin/poweroffln -sf init $(ROOT)/sbin/telinit在终端输入# ls -l /sbin/poweroff# ls -l /sbin/reboot# ls -l /sbin/telinit也可以看到上面的结果。

2、halt。

参数说明:[-n] 防止sync系统调用﹐它用在用fsck修补根分区之后﹐以阻止内核用老版本的超级块〔superblock〕覆盖修补过的超级块。

[-w] 并不是真正的重启或关机﹐只是写wtmp〔/var/log/wtmp〕纪录。

[-d] 不写wtmp纪录〔已包含在选项[-n]中〕。

[-f] 没有调用shutdown而强制关机或重启(halt/reboot)。

[-h] 使硬盘处于standby模式。

[-i] 关掉所有的网络接口。

[-p] 该选项为缺省选项。

就是关机时调用poweroff。

前面已经知道,poweroff、reboot是halt的链接,halt会首先判断用户执行的是否是poweroff和reboot中的一个。

如果执行的是poweroff,则等效于-p参数,执行reboot 的情况将在下面说明。

linux的shutdown命令详解

linux的shutdown命令详解linux下关机我们可以采用shutdown命令来实现,下面由店铺为大家搜集整理了linux的shutdown命令详解的相关知识,希望对大家有帮助!linux的shutdown命令详解命令简介:该命令可以安全关闭或者重新启动系统。

你没有看错,shutdown 命令不仅可以关闭系统、也可以重启Linux系统。

命令语法:/sbin/shutdown [-t sec] [-arkhncfFHP] time [warning-message]命令参数:参数长参数描叙-a Use /etc/shutdown.allow.-c中断关机:当执行"shutdown -h 12:00"指令时,只要按+键就可以中断关机的指令-f重新启动时不进行磁盘检测(fsck)-F重新启动时进行磁盘检测(fsck)-h关闭电源-k模拟关机(不是真的关机),只是向登录者发送警告信息出去!-n不调用init进程进行关机,而是强行关机-r关闭系统然后重新启动,类似于Windows平台restart-t延迟关机的时间-w仅做测试,并不真的将系统重新开机,只会把重开机的数据写入/var/log目录下的wtmp记录文件--help显示命令在线帮助linux的shutdown命令使用示例1: 查看reboot命令的帮助信息[root@db-server ~]# shutdown --helpshutdown: invalid option -- -Usage: shutdown [-akrhHPfnc] [-t secs] time [warning message]-a: use /etc/shutdown.allow-k: don't really shutdown, only warn.-r: reboot after shutdown.-h: halt after shutdown.-P: halt action is to turn off power.-H: halt action is to just halt.-f: do a 'fast' reboot (skip fsck).-F: Force fsck on reboot.-n: do not go through "init" but go down real fast.-c: cancel a running shutdown.-t secs: delay between warning and kill signal.** the "time" argument is mandatory! (try "now") **[root@db-server ~]#[root@db-server ~]# man shutdownSHUTDOWN(8) Linux System Administrator鈥檚Manual SHUTDOWN(8)NAMEshutdown - bring the system downSYNOPSIS/sbin/shutdown [-t sec] [-arkhncfFHP] time [warning-message]DESCRIPTIONshutdown brings the system down in a secure way. All logged-in users are notified that the system is going down, and login(1) is blocked. It is possible to shut the system down immediately or after a specified delay.All processes are first notified that the system is going down by the signal SIGTERM. This gives programs likevi(1) the time to save the file being edited, mail and news processing programs a chance to exit cleanly, etc.shutdown does its job by signalling the init process, asking it to change the runlevel. Runlevel 0 is used tohalt the system, runlevel 6 is used to reboot the system, and runlevel 1 is used to put to system into a statewhere administrative tasks can be performed; this is the default if neither the -h or -r flag is given to shut-down. To see which actions are taken on halt or reboot see the appropriate entries for these runlevels in thefile /etc/inittab.OPTIONS-a Use /etc/shutdown.allow.-t sec Tell init(8) to wait sec seconds between sending processes the warning and the kill signal, beforechanging to another runlevel.-k Don鈥檛really shutdown; only send the warning messages to everybody.-r Reboot after shutdown.-h Halt or poweroff after shutdown.-H Halt action is to halt or drop into boot monitor on systems that support it.-P Halt action is to turn off the power.-n [DEPRECATED] Don鈥檛call init(8) to do the shutdown but do it ourself. The use of this option is dis-couraged, and its results are not always what you鈥檇 expect.-f Skip fsck on reboot.-F Force fsck on reboot.-c Cancel an already running shutdown. With this option it is of course not possible to give the time argu-ment, but you can enter a explanatory message on the command line that will be sent to all users.time When to shutdown.warning-messageMessage to send to all users.The time argument can have different formats. First, it can be an absolute time in the format hh:mm, in whichhh is the hour (1 or 2 digits) and mm is the minute of the hour (in two digits). Second, it can be in the for-mat +m, in which m is the number of minutes to wait. The word now is an alias for +0.If shutdown is called with a delay, it creates the advisory file /etc/nologin which causes programs such aslogin(1) to not allow new user logins. Shutdown removes this file if it is stopped before it can signal init(i.e. it is cancelled or something goes wrong). It also removes it before calling init to change the runlevel.The -f flag means 鈥榬eboot fast鈥? This only creates an advisory file /fastboot which can be tested by the sys- tem when it comes up again. The boot rc file can test if this file is present, and decide not to run fsck(1)since the system has been shut down in the proper way. Afterthat, the boot process should remove /fastboot.The -F flag means 鈥榝orce fsck鈥? This only creates an advisory file /forcefsck which can be tested by the sys- tem when it comes up again. The boot rc file can test if this file is present, and decide to run fsck(1) witha special 鈥榝orce鈥?flag so that even properly unmounted filesystems get checked. After that, the boot process should remove /forcefsck.The -n flag causes shutdown not to call init, but to kill all running processes itself. shutdown will thenturn off quota, accounting, and swapping and unmount all filesystems.ACCESS CONTROLshutdown can be called from init(8) when the magic keys CTRL-ALT-DEL are pressed, by creating an appropriate entry in /etc/inittab. This means that everyone who has physical access to the console keyboard can shut the system down. T o prevent this, shutdown can check to see if an authorized user is logged in on one of the vir-tual consoles. If shutdown is called with the -a argument (add this to the invocation of shutdown in /etc/init-tab), it checks to see if the file /etc/shutdown.allow is present. It then compares the login names in thatfile with the list of people that are logged in on a virtual console (from /var/run/utmp). Only if one of thoseauthorized users or root is logged in, it will proceed. Otherwise it will write the messageshutdown: no authorized users logged into the (physical) system console. The format of /etc/shutdown.allow is one user name per line. Empty lines andcomment lines (prefixed by a #) are allowed. Currently there is a limit of 32 users in this file.Note that if /etc/shutdown.allow is not present, the -a argument is ignored.HALT OR POWEROFFThe -H option just sets the init environment variable INIT_HALT to HALT, and the -P option just sets that vari- able to POWEROFF. The shutdown script that calls halt(8) as the last thing in the shutdown sequence shouldcheck these environment variables and call halt(8) with the right options for these options to actually haveany effect. Debian 3.1 (sarge) supports this.FILES/fastboot/etc/inittab/etc/init.d/halt/etc/init.d/reboot/etc/shutdown.allowNOTESA lot of users forget to give the time argument and are then puzzled by the error message shutdown produces.The time argument is mandatory; in 90 percent of all cases this argument will be the word now.Init can only capture CTRL-ALT-DEL and start shutdown in console mode. If the system is running the X window System, the X server processes all key strokes. Some X11 environments make it possible to capture CTRL-ALT-DEL, but what exactly is done with that event depends on that environment.Shutdown wasn鈥檛designed to be run setuid./etc/shutdown.allow is not used to find out who is executing shut-down, it ONLY checks who is currently logged in on (one of the) console(s).AUTHORMiquelvanSmoorenburg,******************SEE ALSOfsck(8), init(8), halt(8), poweroff(8), reboot(8)November 12, 2003 SHUTDOWN(8)(END)2:马上关闭Linux系统,其中 now 相当于时间为 0 的状态[root@db-server ~]# shutdown -h nowBroadcast message from root (pts/1) (Sat Jan 10 18:51:34 2015):The system is going down for system halt NOW!3:系统2分钟后重新启动,其中+m表示几分钟后关机或开机。

Linux关闭和重启的命令

Linux关闭和重启的命令概要:Linux中常用的关机和重启命令有shutdown、init、halt、reboot、poweroff和telinit,它们都可以达到关机和重新启动的目的,但是每个命令的内部工作过程是不同的,下面将逐一进行介绍。

本文以CentOS5.4 Linux为测试操作系统,所有示例均来自测试系统。

文中所述内容适用于Redhat Linux,但并不适用于所有版本的Linux。

1.各个命令之间的关系shutdown、init、halt、reboot、poweroff和telinit命令都存在于/sbin目录下,我们使用“ls -l”命令查看一下各个命令之间的关系。

如图1。

图1 各个命令之间的关系从图1中我们可以知道,各个命令之间并不都是相互独立的,poweroff和reboot是halt的符号链接,telinit是init的符号链接。

2.shutdown命令语法:shutdown [-krhfnc] [-t secs] time [warning message]只有root用户才有权限执行此命令,因为用户执行shutdown命令时,shutdown会调用getuid判断是否为root用户,如果为普通用户,则会退出。

有些用户会使用直接断掉电源的方式来关闭Linux,这是十分危险的。

因为Linux与Windows不同,其后台运行着许多进程,所以强制关闭机器可能会导致进程的数据丢失,使系统处于不稳定的状态,甚至会损坏硬件设备。

shutdown命令用于安全关闭Linux系统,它在系统关闭之前给系统上的所有登录用户提示一条警告信息。

该命令还允许用户指定一个时间参数,可以是一个精确的时间,也可以是从现在开始的一个时间段。

从语法中,我们可以看到time选项不可以省略。

time选项用于设置多久时间后执行shutdown命令。

time选项的值有hh:mm或+m两种模式。

hh:mm格式表示在几点几分执行shutdown命令。

  1. 1、下载文档前请自行甄别文档内容的完整性,平台不提供额外的编辑、内容补充、找答案等附加服务。
  2. 2、"仅部分预览"的文档,不可在线预览部分如存在完整性等问题,可反馈申请退款(可完整预览的文档不适用该条件!)。
  3. 3、如文档侵犯您的权益,请联系客服反馈,我们会尽快为您处理(人工客服工作时间:9:00-18:30)。
相关文档
最新文档