Article Title: Use the sysrq combination key to understand the system running status. Linux is a technology channel of the IT lab in China. Includes basic categories such as desktop applications, Linux system management, kernel research, embedded systems, and open source.
If the system is suspended or you are diagnosing kernel-related issues that are weird and difficult to reproduce, it is better to use the sysrq key.
How do I enable and disable the SysRq combination key?
For security, SysRq is disabled by default in Red Hat Enterprise Linux.
Enable this function and run:
# Echo 1>/proc/sys/kernel/sysrq
Disable this function:
# Echo 0>/proc/sys/kernel/sysrq
If you want to keep this function effective, set the value of kernel. sysrq in/etc/sysctl. conf to 1. This function will be automatically enabled after it is restarted.
Kernel. sysrq = 1
Because after the sysrq function is enabled, users with terminal access permissions will have some special features. Therefore, do not enable this function unless debugging is required to solve the problem. If you must enable it, ensure the access security of your terminal.
How to trigger a sysrq event?
There are several ways to trigger the sysrq event. On a general system with an AT keyboard, enter the key combination on the terminal:
Alt + PrintScreen + [Command Key]
For example, to allow the kernel to export memory information (CommandKey "m"), you should press both the Alt and Print Screen keys, and then press the m key. tip: This key combination cannot be used on Xwindows. Therefore, you must switch to the text virtual terminal first. If you are using the graphic interface, press Ctrl + Alt + F1 to switch to the virtual terminal.
On the serial port terminal, to achieve the same effect, you must first send the Break signal on the terminal, and then enter the sysrq key combination within five seconds.
If you have the root permission on the machine, you can write the commandkey character to the/proc/sysrq-trigger file. This can help you trigger the sysrq event through scripts or when you are not on the system terminal.
# Echo 'M'>/proc/sysrq-trigger
When I trigger a sysrq event, where is the result saved?
When a sysrq command is triggered, the kernel prints information to the kernel's ring buffer and outputs it to the system console. This information is usually output to/var/log/messages through syslog.
Sometimes, the system may be unable to respond, and syslogd may not be able to record this information. In this case, we recommend that you configure a serial port terminal to collect this information.
Which types of sysrq events can be triggered?
After the sysrq function is enabled, several sysrq events can be triggered. Different kernel versions may be different. But some are shared:
* M-export information about memory allocation
* T-export thread status information
* P-current CPU register information and Flag Information Everywhere
* C-intentionally causing system crash (useful when using netdump or diskdump)
* S-Synchronize all mounted file systems immediately
* U-immediately re-mount all file systems as read-only
* B-restart the system immediately
* O-shut down immediately (if the machine is configured and supports this function)