/proc/sysrq-trigger详解
2016-05-15 07:52
537 查看
原创作品,允许转载,转载时请务必以超链接形式标明文章 原始出处 、作者信息和本声明。否则将追究法律责任。http://itnihao.blog.51cto.com/1741976/830374
https://www.kernel.org/doc/Documentation/sysrq.txt
# 立即重新启动计算机 echo "b" > /proc/sysrq-trigger # 立即关闭计算机 echo "o" > /proc/sysrq-trigger # 导出内存分配的信息 (可以用/var/log/message 查看) echo "m" > /proc/sysrq-trigger # 导出当前CPU寄存器信息和标志位的信息 echo "p" > /proc/sysrq-trigger # 导出线程状态信息 echo "t" > /proc/sysrq-trigger # 故意让系统崩溃 echo "c" > /proc/sysrq-trigger # 立即重新挂载所有的文件系统 echo "s" > /proc/sysrq-trigger # 立即重新挂载所有的文件系统为只读 echo "u" > /proc/sysrq-trigger Documentation for sysrq.c Based on kernel version 2.6.38. Page generated on 2011-03-22 22:20 EST. 1 Linux Magic System Request Key Hacks 2 Documentation for sysrq.c 3 4 * What is the magic SysRq key? 5 ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6 It is a 'magical' key combo you can hit which the kernel will respond to 7 regardless of whatever else it is doing, unless it is completely locked up. 8 9 * How do I enable the magic SysRq key? 10 ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 11 You need to say "yes" to 'Magic SysRq key (CONFIG_MAGIC_SYSRQ)' when 12 configuring the kernel. When running a kernel with SysRq compiled in, 13 /proc/sys/kernel/sysrq controls the functions allowed to be invoked via 14 the SysRq key. By default the file contains 1 which means that every 15 possible SysRq request is allowed (in older versions SysRq was disabled 16 by default, and you were required to specifically enable it at run-time 17 but this is not the case any more). Here is the list of possible values 18 in /proc/sys/kernel/sysrq: 19 0 - disable sysrq completely 20 1 - enable all functions of sysrq 21 >1 - bitmask of allowed sysrq functions (see below for detailed function 22 description): 23 2 - enable control of console logging level 24 4 - enable control of keyboard (SAK, unraw) 25 8 - enable debugging dumps of processes etc. 26 16 - enable sync command 27 32 - enable remount read-only 28 64 - enable signalling of processes (term, kill, oom-kill) 29 128 - allow reboot/poweroff 30 256 - allow nicing of all RT tasks 31 32 You can set the value in the file by the following command: 33 echo "number" >/proc/sys/kernel/sysrq 34 35 Note that the value of /proc/sys/kernel/sysrq influences only the invocation 36 via a keyboard. Invocation of any operation via /proc/sysrq-trigger is always 37 allowed (by a user with admin privileges). 38 39 * How do I use the magic SysRq key? 40 ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 41 On x86 - You press the key combo 'ALT-SysRq-<command key>'. Note - Some 42 keyboards may not have a key labeled 'SysRq'. The 'SysRq' key is 43 also known as the 'Print Screen' key. Also some keyboards cannot 44 handle so many keys being pressed at the same time, so you might 45 have better luck with "press Alt", "press SysRq", "release SysRq", 46 "press <command key>", release everything. 47 48 On SPARC - You press 'ALT-STOP-<command key>', I believe. 49 50 On the serial console (PC style standard serial ports only) - 51 You send a BREAK, then within 5 seconds a command key. Sending 52 BREAK twice is interpreted as a normal BREAK. 53 54 On PowerPC - Press 'ALT - Print Screen (or F13) - <command key>, 55 Print Screen (or F13) - <command key> may suffice. 56 57 On other - If you know of the key combos for other architectures, please 58 let me know so I can add them to this section. 59 60 On all - write a character to /proc/sysrq-trigger. e.g.: 61 62 echo t > /proc/sysrq-trigger 63 64 * What are the 'command' keys? 65 ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 66 'b' - Will immediately reboot the system without syncing or unmounting 67 your disks. 68 69 'c' - Will perform a system crash by a NULL pointer dereference. # 立即重新启动计算机 echo "b" > /proc/sysrq-trigger # 立即关闭计算机 echo "o" > /proc/sysrq-trigger # 导出内存分配的信息 (可以用/var/log/message 查看) echo "m" > /proc/sysrq-trigger # 导出当前CPU寄存器信息和标志位的信息 echo "p" > /proc/sysrq-trigger # 导出线程状态信息 echo "t" > /proc/sysrq-trigger # 故意让系统崩溃 echo "c" > /proc/sysrq-trigger # 立即重新挂载所有的文件系统 echo "s" > /proc/sysrq-trigger # 立即重新挂载所有的文件系统为只读 echo "u" > /proc/sysrq-trigger
相关文章推荐
- Android四大组件说明
- 图片压缩 相互转换【工具类】
- 深度优先搜索(DFS)详解
- MySQL(25):事务的隔离级别出现问题之 不可重复读
- 广度/宽度优先搜索(BFS)详解
- APM/PIX4飞控3G/4G数传实现附源码
- 玩转微信支付全过程
- 结构体、共用体和位运算
- 我读《精进》——04 怎样学习
- 系统架构师-基础到企业应用架构-系列索引
- JSP页面引用JavaScript和Css路径问题
- 如何成为优秀的架构师
- quickstack is a tool to take call stack
- C语言数组
- MySQL ALTER讲解
- 玩转支付宝支付全过程
- perl 变量详解
- .NET Core全新的配置管理[共9篇]
- C#读书雷达 | TW洞见
- 【华为OJ】【065-字符逆序】