14

I'm using the Apple slim aluminum keyboard, which doesn't have the SysRq key:

Apple slim aluminum keyboard

What key(s) should I press for the magic SysRq key when I need to type REISUB?

  • try this, and see this.. seems that you have few options :( – Axel Sep 20 '10 at 13:44
  • Excellent. Some great comments/fixes in the bug report discussion. – Chan-Ho Suh Jan 25 '13 at 21:32
2

I don't have an alu keyboard on hand to test this, but:

System:Preferences:Keyboard Preferences:Keyboard Layout Options:Miscellaneous compatibility options:Apple Alu…

  • What app is that? – cat Nov 15 '16 at 16:09
  • That was the keyboard settings dialogue back on 10.04 accessible through the main system settings. This is ancient, and probably looks a lot different nowadays. I wouldn't know where to find the current equivalent; I haven't used Ubuntu for some time now. – ParanoiaPuppy Nov 15 '16 at 17:16
2

This answer also posted here.

After 3 or 4 hrs of hard searching, reading, and trial and error, here's a more thorough and generic answer which should work for any Apple/Mac laptop or keyboard, not just the "Apple slim aluminum keyboard." In my particular case, however, I'm using this solution for a 2008 MacBook white running Xubuntu 16.04 LTS.

Many thanks to Bengt Olsson for his excellent instructions here which gave me the necessary start to figure out the missing details.

This solution is done in the user space, and does NOT require recompiling the kernel like some suggestions.

  1. Download source for keyfuzz, and extract it (I can right-click it and go to "Extract Here" to extract it in my GUI file manager, for instance). To read more about keyfuzz, see here. It is released under the GNU GPL 2.0 or later open source license (yaaay open source!).

    • Dont' use a directory too deep (or with spaces possibly) or else the ./configure command below will fail.
  2. Install dependencies, or else running ./configure below may spit out some errors:

    sudo apt-get update
    sudo apt-get install lynx xmltoman gengetopt
    
  3. Compile and install keyfuzz with the usual commands:

    ./configure
    make
    sudo make install
    
  4. Navigate to /dev/input/by-id and find your Apple keyboard that ends in -event-kbd:

    cd /dev/input/by-id
    ls
    

    For me it's

    usb-Apple_Computer_Apple_Internal_Keyboard___Trackpad-event-kbd
    
  5. Add the following line to your /etc/rc.local file, to cause this command to run each time your computer boots up and loads this user. Notice we are using the Apple keyboard entry we just found above. This command uses keyfuzz to map F12 or F13 on your Apple keyboard or laptop to the system "Magic SysRq key", for soft reboots.

    • To map F12 to SysRq: 458821 99. Many thanks to "pjjjv" for figuring that out here!
    • To map F13 to SysRq: 458856 99.
    • Since my MacBook 2008 does not have F13, I am using the F12 option above. Also remember to use your proper keyboard entry we found above. The command I added to rc.local for my case is:

      echo "458821 99" | keyfuzz -s -d /dev/input/by-id/usb-Apple_Computer_Apple_Internal_Keyboard___Trackpad-event-kbd
      
    • Here is my entire /etc/rc.local file, with the appropriate entry:

      #!/bin/sh -e
      #
      # rc.local
      #
      # This script is executed at the end of each multiuser runlevel.
      # Make sure that the script will "exit 0" on success or any other
      # value on error.
      #
      # In order to enable or disable this script just change the execution
      # bits.   
      #
      # By default this script does nothing.
      
      echo "458821 99" | keyfuzz -s -d /dev/input/by-id/usb-Apple_Computer_Apple_Internal_Keyboard___Trackpad-event-kbd
      
      exit 0
      
  6. Reboot.

Now I can press Alt+F12 (or you can use Alt+F13 as described above) and issue REISUB to soft-reboot your computer. Works perfectly on my MacBook 2008 laptop running Xubuntu 16.04 LTS.

Note that you can see the results returned by issuing REISUB as you press each key by first jumping to an alternate session with Ctrl+Alt+F1 (F1 through F6 work actually) before issuing the command. To get back to your main X Window session use Ctrl+Alt+F7.

If you get a result that says

This sysrq operation is disabled

that's normal for several of the commands, as they pose a potential security risk. The Boot one should still work, however, allowing you to soft-reboot your computer. Here is some more information on this, from mniess here:

Starting with Ubuntu 12.10 a more fine-grained control of which Magic- SysRq features are enabled is possible. Just edit the file /etc/sysctl.d/10-magic-sysrq.conf.

The file is well documented and tells you exactly how to enable which features. The current default was picked for security purposes and should only be changed if you know why you need to (for security implications see bug #194676).

What a pain in the butt. :) Cheers.
Happy "Linuxing".
~Gabriel Staples
www.ElectricRCAircraftGuy.com

  • I used ` sudo checkinstall -D --install` instead of sudo make install to install keyfuzz as a package. – jarno Jan 13 at 10:36
  • 1
    I used key code 786616 to map Alt + Eject, instead of F12 or F13. – jarno Jan 13 at 10:47
2

Just did this. If you don't want to recompile the kernel like suggested in the first link of the first answer, there is a simpler way. It's kind of outlined in the second link of the first answer, but here is the actual procedure:

  1. Download source for keyfuzz

  2. Compile and install with the usual commands

    ./configure
    make
    sudo make install
    
  3. Add the following line to your /etc/rc.local file:

    echo "458856 99" | sudo /usr/local/sbin/keyfuzz -s -d /dev/input/by-id/usb-Apple__Inc_Apple_Keyboard-event-kbd
    

Now it should be possible to press Alt+F13 and issue REISUB. Worked on my Xubuntu 15.10.

  • I have a MacBook 2008 running Xubuntu 16.04 LTS. This laptop doesn't have F13 :( – Gabriel Staples Mar 25 '17 at 2:47
  • I figured it out! Mapped to F12 instead! Thanks for your answer here which was critical to helping me figure it out. See my answer here: askubuntu.com/a/896806/327339. – Gabriel Staples Mar 25 '17 at 17:04

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.