Linux关机命令详解
关机命令有三个halt,shutdown,poweroff,以及重启命令reboot
halt确有其命令,以及man内容。
shutdown也是专门负责关机的命令,并是独立的程序。
poweroff命令并不存在,但他直接调用的是halt -p的默认命令参数,是link过来的,下面我也提到了
reboot是重启命令,作用内容可以参考halt的man
......
[root@acnis root]# halt --help
usage: halt [-n] [-w] [-d] [-f] [-i] [-p]
-n: don't sync before halting the system
-w: only write a wtmp reboot record and exit.
-d: don't write a wtmp record.
-f: force halt/reboot, don't call shutdown.
-p: power down the system (if possible, otherwise halt)
参数说明:
[-n] 防止sync 系统调用,它用在用fsck修补根分区之后,以阻止内核用老版本的超级块(superblock)覆盖修补过的超级块。
[-w] 并不是真正的重启或关机,只是写 wtmp(/var/log/wtmp)纪录。
[-d] 不写 wtmp 纪录(已包含在选项 [-n] 中)。
[-f] 没有调用 shutdown 而强制关机或"重启"(指的是reboot)。
[-i] 关机(或重启)前,关掉所有的网络接口。
[-p] 该选项为缺省选项。
就是关机时调用 poweroff。
(isher喜欢直接用poweroff命令)
[-h] 在系统关闭之前,从系统中正确的移除所有的磁盘驱动器。
说明poweroff命令很多人不知道,这也是在/sbin下面的命令,是一个link,连接到halt -p的命令上。
[root@acnis sbin]# ll |grep pow
lrwxrwxrwx 1 root root 4 2002-01-13 poweroff -> halt
为了说明,MAN一下poweroff
MAN poweroff(halt)得到以下内容,可以作为对照,对于halt -h
同时包含了halt命令和reboot的解释,因为poweroff本就是halt的快捷方式而已(windows的话)
NAME
halt, reboot, poweroff - stop the system.
SYNOPSIS
/sbin/halt [-n] [-w] [-d] [-f] [-i] [-p] [-h]
/sbin/reboot [-n] [-w] [-d] [-f] [-i]
/sbin/poweroff [-n] [-w] [-d] [-f] [-i] [-h]
OPTIONS
-n Don't sync before reboot or halt.
-w Don't actually reboot or halt but only write the wtmp record (in
the /var/log/wtmp file).
-d Don't write the wtmp record. The -n flag implies -d.
-f Force halt or reboot, don't call shutdown(8).
-i Shut down all network interfaces just before halt or reboot.
-h Put all harddrives on the system in standby mode just before
halt or poweroff.
-p When halting the system, do a poweroff. This is the default when
halt is called as poweroff.
[root@acnis root]# shutdown --help
shutdown: invalid option -- -
Usage: shutdown [-akrhfnc] [-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.
-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") **
参数说明
shutdown 命令可以安全地关闭或重启Linux系统,它在系统关闭之前给系统上的所有登录用户提示一条警告信息。
该命令还允许用户指定一个时间参数,可以是一个精确的时间,也可以是从现在开始的一个时间段。
精确时间的格式是hh:mm,表示小时和分钟;时间段由“ ”和分钟数表示。
系统执行该命令后,会自动进行数据同步的工作。
该命令的一般格式为: shutdown [选项] [时间] [警告信息] 命令中各选项
的含义为:
[-t] seconds : 设定在几秒钟之后进行关机程序
[-k] 并不真正关机,而只是发出警告信息给所有用户。
[-r] 关机后立即重新启动。
[-h] 关机后不重新启动。
[-f] 快速关机,重启动时跳过fsck。
[-F] : 关机时,强迫进行 fsck 动作
[-n] 快速关机,不经过init程序。
[-c] 取消一个已经运行的shutdown。
×需要特别说明的是,该命令只能由超级用户使用。
time : 设定关机的时间
message : 传送给所有使用者的警告讯息
MAN shutdown 得到以下内容,可以作为对照
NAME
shutdown - bring the system down
SYNOPSIS
/sbin/shutdown [-t sec] [-arkhncfF] time [warning-message] OPTIONS
-a Use /etc/shutdown.allow.
-t sec Tell init(8) to wait sec seconds between sending processes the warning and the kill signal, before changing to another run-level.
-k Don't really shutdown; only send the warning messages to every-body.
-r Reboot after shutdown.
-h Halt after shutdown.
-n [DEPRECATED] Don't call init(8) to do the shutdown but do it ourself. The use of this option is discouraged, and its results
are not always what you'd 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 argument, but you can enter
a explanatory message on the command line that will be sent to
all users.。
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终端中常用的系统关机和重启命令,供用户参考和使用。
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终端中,我们可以使用一些命令来控制系统的启动和关机。
本文将详细介绍一些常用的系统启动和关机命令,并探讨它们的功能和使用方法。
一、系统启动命令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 的五个重启命令 1、shutdown 2、poweroff 3、init 4、reboot 5、halt ⼆、五个重启命令的具体说明 shutdown reboot 在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多久以后关机。
linux系统下重启系统、关闭系统、注销系统等相关命令操作
linux系统下重启系统、关闭系统、注销系统等相关命令操作1.KDE快捷键1.KDE快捷键Alt+F1--弹出KDE菜单Alt+F2--弹出“运行"窗口2.用户注销在文字终端中,可以通过下面两种方式:.Exit或Logout.Ctrl+D组合键3.Linux操作系统的关闭与重启init 0:关机,且如果处于多用户模式,不会通知其他用户halt:与init 0类似,但它不会关闭计算机,用户可以Resetshutdown +10:10分钟后关闭计算机shutdown 23:00--23:00关闭计算机,无广播1.shutdownshutdown命令安全地将系统关机。
有些用户会使用直接断掉电源的方式来关闭linux,这是十分危险的。
因为linux与windows不同,其后台运行着许多进程,所以强制关机可能会导致进程的数据丢失o使系统处于不稳定的状态o甚至在有的系统中会损坏硬件设备。
而在系统关机前使用shutdown命令o系统管理员会通知所有登录的用户系统将要关闭。
并且login指令会被冻结o即新的用户不能再登录。
直接关机或者延迟一定的时间才关机都是可能的o还可能重启。
这是由所有进程〔process〕都会收到系统所送达的信号〔signal〕决定的。
这让像vi之类的程序有时间储存目前正在编辑的文档o而像处理邮件〔mail〕和新闻〔news〕的程序则可以正常地离开等等。
shutdown执行它的工作是送信号〔signal〕给init程序o要求它改变runlevel。
Runlevel 0被用来停机〔halt〕orunlevel 6是用来重新激活〔reboot〕系统o而runlevel 1则是被用来让系统进入管理工作可以进行的状态r这是预设的o假定没有-h也没有-r参数给shutdown。
要想了解在停机〔halt〕或者重新开机〔reboot〕过程中做了哪些动作o你可以在这个文件/etc/inittab 里看到这些runlevels相关的资料。
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下有关关机重启的命令主要有: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虚拟机关机、重启命令
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的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终端中,我们也可以通过命令来完成这些操作。
本文将介绍Linux终端中常用的系统重启和关机命令,并详细说明其使用方法。
一、系统重启命令1. shutdownshutdown命令可以安全地关闭Linux系统,并重启系统。
使用该命令需要管理员权限。
使用方法:```shellsudo shutdown -r now```该命令中的"-r"参数表示重启("r"代表reboot),"now"表示立即执行。
因此,执行以上命令后,系统会立即进行重启操作。
2. rebootreboot命令也可以用于重启系统。
与shutdown命令不同的是,reboot命令可以直接在命令行中执行,无需管理员权限。
使用方法:```shellreboot```执行以上命令后,系统会立即进行重启操作。
二、系统关机命令1. shutdownshutdown命令同样可以用于关机操作。
使用方法:```shellsudo shutdown -h now```该命令中的"-h"参数表示关机("h"代表halt),"now"表示立即执行。
因此,执行以上命令后,系统会立即进行关机操作。
2. halthalt命令也可以用于关机操作。
与shutdown命令不同的是,halt命令可以直接在命令行中执行,无需管理员权限。
使用方法:```shellhalt```执行以上命令后,系统会立即进行关机操作。
三、其他相关命令1. initinit命令是Linux系统中的初始化程序,可以用于改变系统的运行级别。
可以使用init命令切换到单用户模式(即命令行模式),然后再执行重启或关机命令。
使用方法:```shellsudo init 1```执行以上命令后,系统会切换到单用户模式。
