I use an apple keyboard at work, I also use ubuntu. There are two things that I need to do to fix the cmd and fn keys with an apple keyboard in linux.
1) modify a file to make the F1-F12 keys work properly (eg, pressing the fn key makes the play, volume buttons, etc work)
The way I get this to work is: (from the ubuntu page here: https://help.ubuntu.com/community/AppleKeyboard)