I use an Apple wired keyboard on Linux. By default the function keys (F1, F2, F3, etc) require the fn key to be pressed for them to work. Without the fn key, these keys control the features like Screen Brightness, Volume, and Music Track Control.

Is there any way to swap these around, so the Function keys do not require the fn modifier, but the other functions (Brightness etc) do?

7 Answers 7


You need to add 0 or 2 into /sys/module/hid_apple/parameters/fnmode.


echo 2 > /sys/module/hid_apple/parameters/fnmode

There seems to be some confusion regarding what the difference between the two values might be. Quoting the Ubuntu documentation:

  1. 0 = disabled : Disable the 'fn' key. Pressing 'fn'+'F8' will behave like you only press 'F8'
  2. 1 = fkeyslast : Function keys are used as last key. Pressing 'F8' key will act as a special key. Pressing 'fn'+'F8' will behave like a F8.
  3. 2 = fkeysfirst : Function keys are used as first key. Pressing 'F8' key will behave like a F8. Pressing 'fn'+'F8' will act as special key (play/pause).

Note that this also works for me on Fedora.

As several people have commented, this change is temporary. You can stick it in your login shell's RC file or into cron so that you don't have to worry about it.

You can also change your driver settings to make this change permanent, like so:

echo options hid_apple fnmode=2 | sudo tee -a /etc/modprobe.d/hid_apple.conf
sudo update-initramfs -u -k all
# reboot when convenient

credits to https://askubuntu.com/a/7553

  • it's fnmode = no underscore Jan 22, 2016 at 15:46
  • 1
    This also works with the M87 keyboard from "velocifire". It is a budget mechanical keyboard but thank you so much for the fix, shows up as an Apple USB device so the apple_hid parameter fix worked for it as well!! So happy can use this kb now. Jun 5, 2020 at 21:25
  • in some systems need 2 in quote: echo "2"> /sys/module/hid_apple/parameters/fnmode and well done. Aug 3, 2020 at 23:20
  • 3
    To make this change permanent (after reboot, the value was reset automatically for me), see askubuntu.com/a/7553/197712 Sep 28, 2020 at 9:40
  • 1
    As @bikashg said, this change is not permanent and making it so should be part of this answer.
    – Shautieh
    Jan 27, 2021 at 1:15

For anyone stumbling upon this thread using one of the newer MacBook Pros (2016 and later) which need the applespi driver to make the keyboard and touchpad work, here's how to make this work, as I couldn't find any other thread explaining this for newer Macs.

As far as I understand, the driver effectively replaces the role of the hid_apple module, so the files to edit are slightly different.

First, to verify that you are using the applespi driver and not the hid_apple driver, check what this command returns (using the terminal). It will tell you which driver you are currently using:

# If this returns "applespi", you are using applespi
ls /sys/module | grep -e applespi -e hid_apple

To test settings temporarily (settings will be reset after a reboot):

echo 2 | sudo tee -a /sys/module/applespi/parameters/fnmode

To apply the changes permanently (persist with reboots):

# Add the option for the fn key
echo options applespi fnmode=2 | sudo tee -a /etc/modprobe.d/applespi.conf
# Update initramfs bootfile
sudo update-initramfs -u -k all
# Reboot to test (optional)
sudo reboot

For older MacBook Pros using the hid_apple module, use "hid_apple" rather than "applespi" in the commands.

  • This helped me out and worked perfectly. Thank you
    – Joel Z.
    May 8, 2020 at 16:08
  • Thank you for the detailed explanation! Nov 14, 2020 at 12:30

I figured out that it is pretty simple to change the behaviour of this modifier, As root change the value in the file /sys/module/hid_apple/parameters/fnmode from 1 to 0. For example:

# echo 0 > /sys/module/hid_apple/parameters/fnmode

Note that in some older versions of linux, this file was located in /sys/module/apple/parameters/fnmode. Also, this change will not persist when you reboot.


For those who get access denied and could not simply prefix "sudo" use:

sudo nano /sys/module/hid_apple/parameters/fnmode

Change it to 2 or whatever and then Ctrl+X to save.

  • better way is to echo 2| sudo tee /sys/module/hid_apple/parameters/fnmode, but all these solutions are transient .... One way to make persistent (on systemd environments like Fedora for example) : echo "w /sys/module/hid_apple/parameters/fnmode - - - - 2" | sudo tee /etc/tmpfiles.d/rev_fn_key.conf
    – nhed
    Oct 11, 2019 at 20:50

In addition, I suggest update the Kernel configurations with the following command:

sudo update-initramfs -u

In an older discussion a solution is given with a kernel boot parameter which might be preferable (system-wide application, modification of just a line in /etc/default/grub, etc).

Only according to that solution, fnmode is set to 2 instead of 0. I just tried to set hid_apple/parameters/fnmode to 2, and it has the desired effect too. Maybe the logic is simply `1 → "require Fn to access F1, F2, F3,..." vs. all other values?

  • 1
    Hi RJVB, welcome to unix.SE. I've edited your answer to improve the formatting. Take a look at the source to learn some of the tricks.
    – drs
    Jun 3, 2014 at 16:10

In addition to @ffledgling's answer:

I suggest the following in order to make this setting being applied on every reboot (works fine on Ubuntu 18.04, 20.04 and I think other distributions as well):

echo "options hid_apple fnmode=2" | sudo tee /etc/modprobe.d/hid_apple.conf

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .