[linux] Swap Caps Lock and Ctrl

Development environment

Linux Ubuntu bionic xfce


  1. localectl
  2. Xmodmap (not recommended)

localectl Actually, there was a way not to use xmodmap! Its name is ** localectl **!!!!!!!!! Win with this guy!

Setting example of US keyboard layout

localectl --no-convert set-x11-keymap us pc105 "" ctrl:swapcaps   

Check the settings

localectl status
System Locale: LANG=ja_JP.UTF-8
   VC Keymap: n/a
  X11 Layout: us
   X11 Model: pc105
X11 Options: ctrl:swapcaps

Location of the config file

It can also be edited and changed directly.

Xmodmap (This method is old! Like an old grandfather's clock)

  1. Find the Caps lock and control keycodes to change
  2. Write two lines in ~ / .Xmodmap.
  3. Reload ~ / .Xmodmap.

Look up the key code


My key code is

--Caps_Lock is 66 --Control_L is 37

It was, so just replace it.

--Changed Caps_Lock to 37 --Changed Control_L to 66

Described in ~ / .Xmodmap

Setting Example

keycode 37 = Caps_Lock
keycode 66 = Control_L

Reload ~ / .Xmodmap

xmodmap ~/.Xmodmap   

Recommended Posts

[linux] Swap Caps Lock and Ctrl
Swap the left Ctrl and left Alt keys while replacing the Caps key with the Ctrl key (Linux, Ubuntu)
lock and Rlock
Linux: files and directories
Studying Linux commands and frustration
Linux (about files and directories)
Device and Linux file system
Addition of amazon linux swap
About LINUX files and processes
Recording and playback on Linux
Linux file and directory permissions
Use the xmodmap command to operate the Caps Lock key as the Ctrl key.