shutdown,init,halt,poweroff,reboot的区别和联系, pkill -kill -t tty7注销
前言
最近这些天,每天晚上关机前,都会在osc上发一条动弹,“我要init 0了,各位晚安啊”,这是一件再正常不过的事情了。
看似很平常的一件事情,不过在昨晚就被一位同学的回复给难住了,到底是什么样的回复呢?让我们继续往下看吧。
从上图我们可以看到,那个回复就是“init 0和halt有区别不。。。。”,我一下就被这个问题给难住了,之前我了解的是init 0 最后调用了halt,但具体的什么区别和联系,真的还不太清楚哦。显然上述不足以回答该同学,且没有任何的说服力。所以带着这样的一个问题,开始了我的探索之路。
相关调研
遇到这个问题的时候,首先想到的还是借助于搜索引擎。最近一段时间我所使用的搜索引擎的顺序有点变化,以前是google-baidu,现在变成了bing-google-baidu(or yandex),不过这两天鉴于google.com.hk情况有点好转,最后还是首选了google一下上述的问题。
经过一番的调研和过滤,现将几个个人认为比较好的回答整理如下(如果想更进一步的了解,可以参考我之后的引用部分):
halt(1M) brings down the machine to the PROM (on SPARC) immediately, with very little regard to running the scripts in /etc/rc[0-6].d to take things down cleanly. reboot(1M) is the same, except instead of just stopping the OS, it reboots the machine.
halt命令直接将机器进入PROM,基本不执行/etc/rc[0-6]脚本去结束一些进程。reboot命令和它一样,除了结束运行操作系统并重启机器。
这种情况下某些进程由于非正常结束可能会导致数据的丢失。
注:PROM stands for programmable read-only memory
init(1M) would run the scripts in /etc/rc[0-6].d to (hopefully) take down the running processes cleanly, and then call halt, reboot, or poweroff(1M) depending on the argument you give it.
init命令将运行/etc/rc[0-6]脚本,该脚本将正常的结束所有正在运行的进程,然后根据你的命令行参数调用halt,reboot或者poweroff命令。
shutdown(1M) allows you to first give a time when the machine will shutdown, prints warnings to users logged in (and possibly to any NFS clients), and then calls init(1M). init then does things like described in the above paragraph.
shutdown命令在机器将要关机之前给了你一段时间,给那些已经登陆到系统的用户(和可能的NFS客户端)打印警告信息,然后调用init,接着init去做上述描述的事情。
//在系统关机前使用shutdown命令﹐系统管理员会通知所有登录的用户系统将要关闭.并且login指令会被冻结﹐即新的用户不能再登录.直接关机或者延迟一定的时间才关机 都是可能的﹐还可能重启.这是由所有进程〔process〕都会收到系统所送达的信号〔signal〕 决定的.这让像vi之类的程序有时间储存目前正在编辑的文档﹐而像处理邮件〔mail〕和 新闻〔news〕的程序则可以正常地离开等等.
shutdown执行它的工作是送信号〔signal〕给init程序﹐要求它改变runlevel.
--来自http://www.chinaunix.net/old_jh/4/16138.html //
Using shutdown or init is usually the best way to go about things AFAIK.
就我目前所知使用shutdown或者init是最好的方式。
注: AFAIK stands for As Far As I Konw
I try to keep in the habit of using shutdown(1M) since by default it gives a grace period before doing things. This way if you're /not/ on the machine you think you are (you're on production, and not a testing server), you still have an opportunity to cancel things before accidentally disrupting service.
综上所述, 基本的依赖关系为:
shutdown->init->/etc/rc[0-6]->halt/reboot/poweroff
Linux注销用户方法
1. 首先使用w或who命令查看登录当前系统的用户
[root@iavp232 ~]# who
root tty7 2013-03-29 13:37 (:0)
root pts/0 2013-07-11 08:47 (192.168.15.32)
root pts/3 2013-03-29 13:37 (:0.0)
2. 使用 pkill 命令将从 tty7 终端登录的用户注销:
[root@centos ~]# pkill -kill -t tty7
其中第 1 个参数 -kill 中的 kill 是 SIGKILL 信号(强制中止程序运行)的缩写。
类似的,如果你要发送 SIGINT 信号(相当于用键盘输入 [ctrl]-c 来中断一个程序的进行),可以:
[root@centos ~]# pkill -int -t pts/3
-t 选项后跟着连接终端的名称
shutdown,init,halt,poweroff,reboot的区别和联系, pkill -kill -t tty7注销的更多相关文章
- 简单理解Busybox下halt/poweroff/reboot实现及区别
关键词:halt/poweroff/reboot.reboot().SIGUSR1/SIGTERM/SIGUSR2等. 1. busybox下的halt/poweroff/reboot实现 通过app ...
- Linux下关机命令的区别 (halt,poweroff,reboot,shutdown,init)
1.shutdown shutdown命令安全地将系统关机. 而在系统关机前使用shutdown命令﹐系统管理员会通知所有登录的用户系统将要关闭.并且login指令会被冻结﹐即新的用户不能再登录 ...
- 【摘】linux之shutdown、halt和reboot命令详解
在重新启动Linux系统的同时把内存中的信息写入硬盘,应使用()命令实现 #shutdown -r now #halt #reboot #init3 正确答案:A 在linux命令中reboot是 ...
- 正确的关机方法: sync, shutdown, reboot, halt, poweroff, init
正常情况下,要关机时需要注意底下几件事: 观察系统的使用状态: 如果要看目前有谁在在线,可以下达『who』这个命令,而如果要看网络的联机状态,可以下达 『 netstat -a 』这个命令, 而要看背 ...
- Linux命令——shutdown、halt、poweroff、reboot、cal、date
shutdown shutdown在关机的时候会通知所有用户 shutdown –r now 现在重启 shutdown now 现在关机 shutdown +5 过5分钟关机 shutdown –c ...
- 理解Linux中的shutdown、poweroff、halt和reboot命令
原文 http://os.51cto.com/art/201706/541525.htm 在本篇中,我们会向你解释 shutdown.poweroff.halt 以及 reboot 命令.我们会 ...
- 【2016-10-11】Linux系统常用的关机或重启命令shutdown、reboot、halt、poweroff、init 0及init 6的联系与区别
Linux下常用的关机/重启命令一般包括: shutdown.reboot.halt.poweroff等,当然了我们可以使用init 运行等级runlevel 0即halt来关机,或使用init 运行 ...
- init()和onEnter()方法的区别
init()和onEnter()这俩个方法都是CCNode的方法.其区别如下: 1.其被调用的顺序是先init(),后onEnter(). 2.init()在类的初始化时只会调用一次. 3.onEnt ...
- initialize和init以及load方法的区别与使用以及什么时候调用
initialize不是init initialize在这个类第一次被调用的时候比如[[class alloc]init]会调用一次initialize方法,不管创建多少次这个类,都只会调用一次这个方 ...
随机推荐
- iOS调试程序时,启动应用失败的解决办法
最近在iOS项目中调试程序,项目中用到第三方应用来启动我的应用程序,调试阶段在实体机上用第三方应用启动我的应用时,出现如下错误,程序停止运行: 同时,在AppDelegate对象的如下方法中设置断点: ...
- Razor引擎学习:RenderBody,RenderPage和RenderSection
ASP.NET MVC 3 已经正式发布了,现在估计许多人都在拼命学,我也不能例外,刚刚看到了一篇文章,介绍了三个非常有用的方法:RenderBody,RenderPage和RenderSection ...
- 转:ASP.NET MVC 3 and App_Code folder
问题: In ASP.NET Webform, App_Code is standardfolder to putting code and using it at run-time.But I th ...
- Codevs 3289 花匠 2013年NOIP全国联赛提高组
3289 花匠 2013年NOIP全国联赛提高组 时间限制: 1 s 空间限制: 128000 KB 题目等级 : 钻石 Diamond 题目描述 Description 花匠栋栋种了一排花,每株花都 ...
- <<深入Java虚拟机>>-第三章-垃圾收集器与内存分配策略-学习笔记
垃圾收集 垃圾收集(Garbage Collection,GC),垃圾收集需要完成的三件事情. 哪些对象需要回收 什么时候回收 如何回收 如何确定对象已死(即不可能在被任何途径引用的对象) 引用计数算 ...
- source和.命令的区别
source FileName 作用:在当前bash环境下读取并执行FileName中的命令. 注:该命令通常用命令“.”来替代. 如:source .bash_rc 与 . .bash_rc 是等效 ...
- apply()与call()的区别
一直都没太明白apply()与call()的具体使用原理,今日闲来无事,决定好好研究一番. JavaScript中的每一个Function对象都有一个apply()方法和一个call()方法,它们的语 ...
- aspx页面状态管理(查询字符串Request与Application)
1,Request:可以方便的将信息从一个页面传递到另一个页面,通过url传递,不安全,数据量小,只能通过http-get提交的才可以 2,Application对象:()本质上是Hash表)所有访问 ...
- PHP学习心得(四)——基本语法
从 HTML 中分离 当 PHP 解析一个文件时,会寻找开始和结束标记,标记告诉 PHP 开始和停止解释其中的代码.此种方式的解析可以使 PHP 嵌入到各种不同的文档中,凡是在一对开始和结束标记之外的 ...
- css text-overflow溢出文本显示省略号
<div style="width: 100px; overflow: hidden; text-overflow:ellipsis"> <nobr>当对象 ...