Configure the keyboard for your Macbook and Ubuntu 12.04 (and 12.10)

Configure the keyboard for your Macbook and Ubuntu 12.04 (and 12.10)

I love the new Ubuntu 12.04 Precise Pangolin. Unity – and the graphics drivers – have finally reached a stability that satisfies me and let me keep GNU/Linux as solo operating systems on my Macbook Pro 6,2.

What drives me crazy is the default keyboard mapping, surely not thought for who owns an Apple computer.

First, the Unity Launcher (a.k.a. Dash) default shortcut is the Super key (or Win key). This key corresponds to the cmd key on Apple keyboards.
Under Mac OS X, the combination cmd+space opens Spotlight, while cmd+c, cmd+v are for Copy&Paste. That is, the cmd key is a supercharged ctrl key.

I spent some time to search the best combinations to reproduce this behavior under Ubuntu.
Here is what I managed to create:

  • I swapped the left ctrl and the left/right cmd keys. That is, cmd becomes ctrl and ctrl becomes cmd
  • After the first modification, it becomes unconvenient to open Dash with the ctrl key. Therefore, I changed Unity Launcher key to cmd+space. This (sort of) emulates OS X behavior.

To implement the first tweak, create the file ~/.Xmodmap with the following content:

Logout and login again.
Congratulations, you have the swapped keys. Ubuntu should already take care to load the file automatically.

It is important to not manually load the .Xmodmap file. It may result in a double application of the mappings, resulting in a re-swap of the keys.

To achieve the second tweak, install the package compizconfig-settings-manager.
Open it using the ccsm command, or search for it in Dash.
Find Ubuntu Unity Plugin->Behavior->Key to show the launcher and change it to <Primary>space, using the Grab key combination button. It may be also shown as <Control><Primary>space.

You can now have a behavior similar to Mac OS X in Ubuntu 12.04. You can change the virtual desktop using cmd+alt+arrow. You can cut, copy, and paste using cmd+x, cmd+c, and cmd+v. You can open the Unity launcher with cmd+x.

I hope that this little how-to can help frustrated Apple users who want to embrace GNU/Linux freedom.

(Featured Image credits: Marco Antonio Islas Cruz)

Share Button


  1. I tried doing this as well but it just doesn’t fit the keyboard scheme in Ubuntu so I just reverted back. I somehow already have a feel for the keyboard shortcuts anyway since I’ve used both Windows and mac.

    • In which sense it does not fit the keyboard scheme? Are there no more working keys on your keyboard after my instructions?
      By the way, I re-installed Ubuntu 12.04 today and I can confirm this tutorial is working for me.

  2. Hello, does the cmd+space work with Gnome 3 instead of Unity? The first tweak worked great but I cannot get the second to work. Any help appreciated.

  3. I’m using a Mac keyboard on Linux Mint 13 – Mate. I selected an option for the command key to act like a control key. This is OK for most things, but in Terminal it doesn’t work because it does a ^C. How can I get this to work so it also allows me to do COPY/PASTE using the Command key in the Terminal program? Thanks!

    • The ^C you see is what should happen if the mapping has been successful. CTRL+C (or ^C) in a terminal is for sending a SIGINT signal to the active program (i.e., to kill it).
      This behavior is the same under OS X and GNU/Linux. However, Apple Computers have both the CTRL and the CMD keys. That is why you can have this very convenient COPY/PASTE thing in the Terminal program.
      I do not think that this is implemented in any GNU/Linux desktop environment. Try to follow the instructions posted here. They may work for you.

    • Edward – can you tell me where that option is / which keyboard layout I can find it in? That’s exactly what I’m looking for!

  4. Brilliant post! I think it proved very useful for me in making more out of keyboard functionality. Next time, you should post on mouse gesture functionality on the mac.

    Anyway, the trick worked great. But although my left cmd button works, the right cmd button doesn’t. How can I solve this? Thanks.

    • Hello John, it works for me with both CMD keys.
      Can you double check if the the .Xmodmap files contains these two lines?

  5. I had this working for a long time, but now Quantal Quetzal do not seem to load .Xmodmap on login and I had to load the file manually on the command line. Further, sometimes after suspend/resume I lost the configuration (not always) and have to run the command again. Any ideas?

    • That is rather strange. I have upgraded to Quanta Quetzal since two days and everything still works fine.
      Are you sure .Xmodmap isn’t loaded twice instead?

  6. After many unsuccessful experiences, finally this worked.
    Thanks man.

  7. For me the .Xmodmap file is not loaded when I restart (the system logged in automatically) on Quantal.

    Also, I have this little (but really annoying) problem: cmd+s (for saving a file) does not work as expected, instead it starts echo, the workspaces overview. I tried to disable this via the compizconfig manager but no luck.

    Any ideas?

    • There are reports on strange behaviors from other users as well. Is only cmd+s not working? Do shortcuts for copy and paste (cmd+c, cmd+v) work? That would look rather strange.

  8. This works fine on Ubuntu 13.04. Thanks!

  9. Thank you for posting this! Another OS X saved from frustration. :)

  10. This is excellent, thanks!

    One thing I’m not sure about though, is how to get the hash key working. I found a way, which involved modifying the 3rd level key mapping in the keyboard layout, but then it messes up the above fix.

    Anyone know anything about this?

    • I have never had this issue. Hopefully somebody can help.
      P.S. keep up the good work at I am a very satisfied customer :-)

  11. It’s no longer work on Ubuntu 13.10 :(



  1. Remapping some keys on the keyboard for MBA under Ubuntu | Robby Chen personal blog - […] […]

Submit a Comment

Your email address will not be published. Required fields are marked *

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code class="" title="" data-url=""> <del datetime=""> <em> <i> <q cite=""> <strike> <strong> <pre class="" title="" data-url=""> <span class="" title="" data-url="">