原创作品,允许转载,转载时请务必以超链接形式标明文章 原始出处 、作者信息和本声明。否则将追究法律责任。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.. Page generated on -- : EST. Linux Magic System Request Key Hacks
Documentation for sysrq.c * What is the magic SysRq key?
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
It is a 'magical' key combo you can hit which the kernel will respond to
regardless of whatever else it is doing, unless it is completely locked up. * How do I enable the magic SysRq key?
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
You need to say "yes" to 'Magic SysRq key (CONFIG_MAGIC_SYSRQ)' when
configuring the kernel. When running a kernel with SysRq compiled in,
/proc/sys/kernel/sysrq controls the functions allowed to be invoked via
the SysRq key. By default the file contains which means that every
possible SysRq request is allowed (in older versions SysRq was disabled
by default, and you were required to specifically enable it at run-time
but this is not the case any more). Here is the list of possible values
in /proc/sys/kernel/sysrq:
- disable sysrq completely
- enable all functions of sysrq
> - bitmask of allowed sysrq functions (see below for detailed function
description):
- enable control of console logging level
- enable control of keyboard (SAK, unraw)
- enable debugging dumps of processes etc.
- enable sync command
- enable remount read-only
- enable signalling of processes (term, kill, oom-kill)
- allow reboot/poweroff
- allow nicing of all RT tasks You can set the value in the file by the following command:
echo "number" >/proc/sys/kernel/sysrq Note that the value of /proc/sys/kernel/sysrq influences only the invocation
via a keyboard. Invocation of any operation via /proc/sysrq-trigger is always
allowed (by a user with admin privileges). * How do I use the magic SysRq key?
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
On x86 - You press the key combo 'ALT-SysRq-<command key>'. Note - Some
keyboards may not have a key labeled 'SysRq'. The 'SysRq' key is
also known as the 'Print Screen' key. Also some keyboards cannot
handle so many keys being pressed at the same time, so you might
have better luck with "press Alt", "press SysRq", "release SysRq",
"press <command key>", release everything. On SPARC - You press 'ALT-STOP-<command key>', I believe. On the serial console (PC style standard serial ports only) -
You send a BREAK, then within seconds a command key. Sending
BREAK twice is interpreted as a normal BREAK. On PowerPC - Press 'ALT - Print Screen (or F13) - <command key>,
Print Screen (or F13) - <command key> may suffice. On other - If you know of the key combos for other architectures, please
let me know so I can add them to this section. On all - write a character to /proc/sysrq-trigger. e.g.: echo t > /proc/sysrq-trigger * What are the 'command' keys?
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
'b' - Will immediately reboot the system without syncing or unmounting
your disks. '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