{"id":1540,"date":"2017-05-26T08:44:57","date_gmt":"2017-05-26T12:44:57","guid":{"rendered":"https:\/\/easy-admin.ca\/?p=1540"},"modified":"2017-07-12T20:56:23","modified_gmt":"2017-07-13T00:56:23","slug":"understanding-the-sysrq-key-the-magic-key-to-control-linux","status":"publish","type":"post","link":"https:\/\/easy-admin.ca\/index.php\/2017\/05\/26\/understanding-the-sysrq-key-the-magic-key-to-control-linux\/","title":{"rendered":"Understanding the SysRq Key \u2013 The Magic Key To Control Linux"},"content":{"rendered":"<p>Linux do crash. It is not so frequent, but it happens. You know what to do when an application refuses to obey, but if everything fails, the last solution is using the supreme power on Linux: the magic <em>SysRq<\/em> key. By using this key with a combination of \u201cAlt\u201d and another letter, you will be able to make your computer respond no matter what. It was already evoked, but a little explanation does not hurt, and the more you know, the more prepared you will be when facing a real problem. Also, understanding the individual effect is always better than just repeating a combo learned by heart.<\/p>\n<h2 class=\"nolinks\">How To Activate The Magic Key<\/h2>\n<p>As said before, the magic key is super handy. But first, you have to activate this functionality if it is not already done. To check, use the command<\/p>\n<div class=\"holsh-div\">\n<div class=\"bash\">\n<pre>cat \/proc\/sys\/kernel\/sysrq<\/pre>\n<\/div>\n<\/div>\n<p>If it returns a 1, the Magic Key is working. If it is a 0, you will need to activate it. In most cases, if you want to activate it temporarily, you can try<\/p>\n<div class=\"holsh-div\">\n<div class=\"bash\">\n<pre>sudo echo \"1\" &gt; \/proc\/sys\/kernel\/sysrq<\/pre>\n<\/div>\n<\/div>\n<p>But this did not work for me. So under Archlinux, I used instead:<\/p>\n<div class=\"holsh-div\">\n<div class=\"bash\">\n<pre>sudo sysctl kernel.sysrq=1<\/pre>\n<\/div>\n<\/div>\n<p>Note that this will be only temporary. If you want the Magic Key to work even after a reboot, the best way is to edit the file \u201c\/etc\/sysctl.conf\u201d, so that the line<\/p>\n<div class=\"holsh-div\">\n<div class=\"bash\">\n<pre>kernel.sysrq = 0<\/pre>\n<\/div>\n<\/div>\n<p>becomes<\/p>\n<div class=\"holsh-div\">\n<div class=\"bash\">\n<pre>kernel.sysrq = 1<\/pre>\n<\/div>\n<\/div>\n<h2 class=\"nolinks\">List of Useful Combinations<\/h2>\n<p>The whole point of using the Magic SysRq key is to combine it with the \u201cAlt\u201d key and another letter in order to trigger a particular function, even if your computer seems frozen. To begin, you should know that this System Request key is usually sharing its location with the \u201cPrint Scrn\u201d key at the top right of your keyboard. Above the \u201cInsert\u201d key, and left to \u201cScroll Lock.\u201d<\/p>\n<p><img loading=\"lazy\" decoding=\"async\" class=\"alignnone wp-image-1541 size-full\" src=\"https:\/\/easy-admin.ca\/wp-content\/uploads\/2017\/05\/magic_key-keyboard_location.png\" alt=\"\" width=\"600\" height=\"186\" srcset=\"https:\/\/easy-admin.ca\/wp-content\/uploads\/2017\/05\/magic_key-keyboard_location.png 600w, https:\/\/easy-admin.ca\/wp-content\/uploads\/2017\/05\/magic_key-keyboard_location-300x93.png 300w\" sizes=\"auto, (max-width: 600px) 100vw, 600px\" \/><\/p>\n<p>As you can guess, the effect of the combination depends on which letter key is used. Here is a non-exhaustive list of letter you can use to obtain an interesting result.<\/p>\n<ul>\n<li>b \u2013 reboots the computer<\/li>\n<li>e \u2013 ask all processes to terminate gracefully<\/li>\n<li>f \u2013 to get rid of an Out Of Memory condition via oom_kills<\/li>\n<li>i \u2013 to kill all processes immediately except init<\/li>\n<li>k \u2013 to kill absolutely all processes, including X<\/li>\n<li>m \u2013 to output the current memory information<\/li>\n<li>o \u2013 to shut down the computer<\/li>\n<li>r \u2013 very useful, to take the keyboard out of the X server control<\/li>\n<li>s \u2013 to sync data from all mounted devices (avoid data loss in case of violent reboot)<\/li>\n<li>t \u2013 to display a list of the current tasks<\/li>\n<li>u \u2013 to remount all file system in read-only mode<\/li>\n<\/ul>\n<h2 class=\"nolinks\">Famous Examples<\/h2>\n<p>Every Linux user should know these examples. If your X server is frozen and you cannot access any virtual console, using \u201cAlt + SysRq + r\u201d should take the keyboard away from the X server and let you perform \u201cCtrl + Alt + F1\u201d in order to get to a terminal and kill the appropriate processes.<\/p>\n<p>If you do not have the patience to do that, \u201cAlt + SysRq + k\u201d will kill everything in the same way as \u201cCtrl + Alt + Backspace\u201d (but more violently).<\/p>\n<p>If nothing responds at all, and the only way is to reboot your computer, the classical combo is \u201c<em>reisub<\/em>\u201d for \u201cRaising Elephant Is So Utterly Boring\u201d, or just remember the opposite of \u201c<em>busier<\/em>\u201c. Use each letter of this anagram with the magic key in order to:<\/p>\n<ul>\n<li>Take the keyboard from X<\/li>\n<li>Ask all programs to end gently<\/li>\n<li>Kill the one who did not<\/li>\n<li>Save the data from the cache to the hard drive<\/li>\n<li>Remounts the file systems<\/li>\n<li>Reboot<\/li>\n<\/ul>\n<h2 class=\"nolinks\">Conclusion<\/h2>\n<p>The idea is that the magic key combinations are generally super violent. You do not want anybody to use it on your computer while you are not looking. But as a last resort, it can become the ultimate tool. I rarely encountered a situation where SysRq did not respond. So when your Linux does not obey its master, you know what to do.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>Linux do crash. It is not so frequent, but it happens. You know what to do when an application refuses to obey, but if everything fails, the last solution is using the supreme power on Linux: the magic SysRq key. By using this key with a combination of \u201cAlt\u201d and another letter, you will be &hellip; <a href=\"https:\/\/easy-admin.ca\/index.php\/2017\/05\/26\/understanding-the-sysrq-key-the-magic-key-to-control-linux\/\" class=\"more-link\">Continue reading <span class=\"screen-reader-text\">Understanding the SysRq Key \u2013 The Magic Key To Control Linux<\/span><\/a><\/p>\n","protected":false},"author":2,"featured_media":0,"comment_status":"closed","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"slim_seo":{"title":"Understanding the SysRq Key \u2013 The Magic Key To Control Linux - HP Server","description":"Linux do crash. It is not so frequent, but it happens. You know what to do when an application refuses to obey, but if everything fails, the last solution is us"},"footnotes":""},"categories":[1],"tags":[],"class_list":["post-1540","post","type-post","status-publish","format-standard","hentry","category-general"],"_links":{"self":[{"href":"https:\/\/easy-admin.ca\/index.php\/wp-json\/wp\/v2\/posts\/1540","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/easy-admin.ca\/index.php\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/easy-admin.ca\/index.php\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/easy-admin.ca\/index.php\/wp-json\/wp\/v2\/users\/2"}],"replies":[{"embeddable":true,"href":"https:\/\/easy-admin.ca\/index.php\/wp-json\/wp\/v2\/comments?post=1540"}],"version-history":[{"count":0,"href":"https:\/\/easy-admin.ca\/index.php\/wp-json\/wp\/v2\/posts\/1540\/revisions"}],"wp:attachment":[{"href":"https:\/\/easy-admin.ca\/index.php\/wp-json\/wp\/v2\/media?parent=1540"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/easy-admin.ca\/index.php\/wp-json\/wp\/v2\/categories?post=1540"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/easy-admin.ca\/index.php\/wp-json\/wp\/v2\/tags?post=1540"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}