There are a few ways to achieve this behaviour. It depends a bit on the type of System you're using.
Xorg
You already added xmodmap
as a tag to your question, so you probably already know about that.
xmodmap
Referencing the Arch Linux Wiki, you can remap Caps Lock to Tab with
setxkbmap -option caps:tab
Please make sure to add this option to your startup script, e.g. in .xinitrc
, as this config will reset itself when rebooting because of how Linux loads your Keymap.
custom keymap and loadkeys
Another way would be using a custom keymap.
Add to /usr/local/share/kbd/keymaps/personal.map
:
keycode 58 = Tab
keycode 15 = Caps_Lock
And using loadkeys
to load the remapped key layout:
loadkeys /usr/local/share/kbd/keymaps/personal.map
Wayland
Reference: How to customise keyboard mappings with Wayland