Linux: Swap Control Alt Keys

By Xah Lee. Date: . Last updated: .

This page shows you how to swap {Ctrl, Alt} keys on Linux.

Create a file at ~/.Xmodmap. The file content should be this:

! -*- coding: utf-8 -*-
! 2013-02-04

! swap Ctrl and Alt keys

! here's the default setting on special keys
!  xmodmap -pke | grep -P '(Control|Super|Alt|Menu)'

! keycode  37 = Control_L NoSymbol Control_L
! keycode  64 = Alt_L Meta_L Alt_L Meta_L
! keycode 105 = Control_R NoSymbol Control_R
! keycode 108 = Alt_R Meta_R Alt_R Meta_R
! keycode 133 = Super_L NoSymbol Super_L
! keycode 134 = Super_R NoSymbol Super_R
! keycode 135 = Menu NoSymbol Menu
! keycode 147 = XF86MenuKB NoSymbol XF86MenuKB
! keycode 204 = NoSymbol Alt_L NoSymbol Alt_L
! keycode 206 = NoSymbol Super_L NoSymbol Super_L

clear control
clear mod1
keycode 37 = Alt_L Meta_L
keycode 105 = Alt_R Meta_R
keycode 64 = Control_L
keycode 108 = Control_R
add control = Control_L Control_R
add mod1 = Alt_L Meta_L

Now, run this line in terminal:

xmodmap ~/.Xmodmap

That's it. When X11 starts, that file will be loaded automatically.

For Mac and Microsoft Windows, see

Linux Keybinding

  1. Keyboard Software Guide
  2. Swap Control Alt Keys
  3. Set F2 F3 F4 to Cut Copy Paste
  4. Swap CapsLock Escape Keys
  5. Make CapsLock Do Home Key
  6. Setup Shift Lock Key
  7. Add Keyboard Shortcut to Switch App
  8. Set Key Repeat Rate
  9. Set System Keyboard Layout
  10. How to Switch to Dvorak Keyboard Layout
  11. Change Volume by Command
  12. xmodmap
  13. xbindkeys
  14. xvkbd
  15. Find Keyboard Key Scancode
  16. X11 Keyboard Key Names

If you have a question, put $5 at patreon and message me.