Write down the linux magic keys to avoid forgetting them.
Source: Internet
Author: User
For the linux magic key, write down the Linux universal technology-Linux programming and kernel information. The following is a detailed description. According to the Linux kernel documentation:
This is a group of 'Magic composite keys'. As long as the kernel is not fully locked, no matter what the kernel is doing, using these composite keys can immediately print the kernel information.
Using the sysrq combination key is the best way to understand the current running status of the system. 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 + [CommandKey]
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 do I save it?
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)
The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion;
products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the
content of the page makes you feel confusing, please write us an email, we will handle the problem
within 5 days after receiving your email.
If you find any instances of plagiarism from the community, please send an email to:
info-contact@alibabacloud.com
and provide relevant evidence. A staff member will contact you within 5 working days.
A Free Trial That Lets You Build Big!
Start building with 50+ products and up to 12 months usage for Elastic Compute Service