Each time I start Ubuntu (20.04) I always need to start a terminal and run:

echo 2 | sudo tee /sys/module/hid_apple/parameters/fnmode

Since its for some reason not possible to configure Function Keys behavior permanently in the system setting (See On an Apple Keyboard under Linux, how do I make the Function keys work without the fn modifier key?)

But can I at least add the above command to some init script that will be executed automatically each time Ubuntu starts even though it requires sudo/root permissions?

  • Hm why the down vote? Does not seem like a completely trivial question o that its lacking details. Also based on the answers there is also some good knowledge to be shared it seems
    – u123
    Jul 30, 2020 at 19:25

3 Answers 3


Your command actually sets a parameter for the hid_apple kernel module.

If the module is not compiled into the kernel, you could just create a text file named /etc/modprobe.d/hid_apple.conf with the following contents:

options hid_apple fnmode=2

This is the standard way of setting module parameters persistently.

You could name the file anything you want, as long as you put it into /etc/modprobe.d/ directory and the name has a .conf suffix.


You could add the following to root's cron (with sudo crontab -e):

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

You could

You must log in to answer this question.

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