Ask Ubuntu is a question and answer site for Ubuntu users and developers. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I have scoured the web, and I can't seem to get Xmodmap / anything to work properly. I want to swap BOTH my Command keys with my Control key - in essence, inverting what they do currently.

How would I do that?

I tried xmodmap -e "keycode 133 = Control_L" and corresponding commands for keycodes 134 (right command) and 37 (control left). I even tried these commands, plus xmodmap -pke > ~/.Xmodmap and xmodmap ~/.Xmodmap in .xinitrc.

My end goal is I want HUD / Dash to come up when I click control and command to functional control, i.e., control-v is a commond shortcut to paste, i would click command-v

share|improve this question
up vote 38 down vote accepted

I figured it out. Put the following in ~/.Xmodmap:

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

To test, run the command:

xmodmap ~/.Xmodmap

To make it run every time, add it to Startup Applications.

This should work on any MacBook Pro; the issue was that Xmodmap was assigning Super_L to the left and right command keys, and Control_L to the left control key. For some reason, by default, Ubuntu thinks that the MacBook Pro has a standard 105 key keyboard (probably thinking about the full Apple Keyboard) but that is wrong. Anyway, I reassigned the keycodes to the right keysims, then assigned the keysims to control and mod4.

share|improve this answer
I have an extra question: how can I change the left Control key to become the alt key, and viceversa, the alt key next to the left Control key to become the left Control key? – 719016 Jun 1 '15 at 15:45
how do I keep the right hand side win button working? – arcanine Jun 24 at 12:40

Go into System -> Preferences -> Keyboard

Click on the "Layouts" tab and then click the "Layout Options" button.

Click on "Alt/Win key behavior"

Select "Control is mapped to Win keys (and the usual ctrl key).


share|improve this answer
Just a note - this doesn't swap the keys, it just makes the command keys additional control keys. – Fabian Tamp Aug 6 '13 at 4:08

Go to system settings and then to keyboard layout, then to options, then to Win/Alt key behavior, and then check the "Meta switches Ctrl" and then in the Ctrl Position check "Ctrl switches Meta" and there you have it!

on 12.04.1 you change this by:

First, going to "System Settings" then clicking on "Keyboard" then "Layout Settings" (in the bottom left), then "Options" in the bottom right, then expanding the "Alt/Win key behavior" tab, then selecting "Control is mapped to win Keys (and the usual Ctrl keys)"

share|improve this answer
Worked for me in 12.04. I can't actually believe it, but it worked. After hours of messing with .xmodmap – jyoseph Jan 4 '13 at 22:55
This is great, thanks. I have the newer system (what you describe in the second paragraph). Ctrl is mapped to Win keys makes Cmd behave as Ctrl. Ctrl key position -> Left Ctrl as Meta does the opposite. Also as a side note, I had to go to Startup and Shutdown -> Service Manager -> Startup Services and activate Keyboard Daemon (this was off by default). – 0__ Feb 20 '14 at 14:16
14.04 doesn't seem to have that "Options" link. – Waldir Leoncio Apr 14 '15 at 11:22
As for Ubuntu 15.04, this option is available now at "Input Devices>Keyboard>Advanced tab>Alt/Win key behaviour section>Ctrl is mapped to win Keys (and the usual Ctrl keys)" – Serj Zaharchenko Apr 8 at 9:18
Cant find any of that on Ubuntu 16.04 – Houman Apr 30 at 18:45

I just installed Ubuntu 16.04 dual boot on my MBP13" yesterday. For Ubuntu 16.04, here's how i did it:

Step 1: Launch terminal

Step 2: Edit X Keyboard Extension

nano /usr/share/X11/xkb/symbols/pc

Step 3: Make the following changes. Ensure your file looks like this:

key <LCTL> {    [ Super_L       ]   };
key <LWIN> {    [ Control_L     ]   };
key <RCTL> {    [ Super_R       ]   };
key <RWIN> {    [ Control_R     ]   };

Step 4: Clear xkb's cache

rm -rf /var/lib/xkb/*

Step 5 (conditional): If the keys are not swapped after step 4, restart your computer. It worked for me after this.

Hope it helps, good luck!

share|improve this answer

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.