using Mac computers for few years, I got accustomed of using the Cmd key on the keyboard as a standard Ctrl key.

With Ubuntu 13.04 on my Macbook Pro 5,3 (2009), the Cmd is used for Unity controls, and Ctrl for applications shortcuts. Is there any way to switch the two keys? So that, as an example, close a tab in Firefox would be Cmd+W instead of Ctrl+W?

  • Found the answer here : askubuntu.com/questions/131900/… but with 13.04 you must edit an xmodmap file in your /home folder because there is no more a "layout" option in Parameters > System > Keyboard. – greguti Jul 7 '13 at 16:14
  • If you have solved your problem, it would be helpful to write up your solution as an answer. If you put your answer on askubuntu.com/questions/131900/… and edited the question to cover both versions of Ubuntu then this question could be closed as a duplicate. – David Edwards Jul 8 '13 at 12:06

I found out a workaround. The solution is to use the xmodmap utility and make it load a personal file with the correct mapping for the keyboard.

  1. Open a terminal and create a new file in your /home folder, lets call it .Xmodmap

    nano .Xmodmap

    (I use nano as a nice text editor inside the console, you can use Gedit instead, install nano with the command sudo apt-get install nano if you'd like to test it, it's quite obvious to handle.)

  2. Copy/paste the following content to the new file:

    clear control
    clear mod4
    keycode 105 =
    keycode 206 =
    keycode 133 = Control_L NoSymbol Control_L
    keycode 134 = Control_R NoSymbol Control_R
    keycode 37 = Super_L NoSymbol Super_L
    add control = Control_L
    add control = Control_R
    add mod4 = Super_L
  3. Make the file executable.

    chmod +x .Xmodmap
  4. Test it now with the following command:

    xmodmap .Xmodmap

    The dash should now appear with Ctrl instead of CMD, hurra!

  5. Now we want the file to be executed each time the system starts up. Open the Startup Applications utility and add a new entry, name it as you want and put the following comand in it:

    /user/bin/xmodmap /home/YOURUSERNAME/.Xmodmap

Reboot, it should be ok. If it is not, you should add a .xinitrc file in your /Home folder, and add the command inside it. The .xinitrc file will be read by the system while loading the desktop environment.

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.