David Härer / Cheatsheets

Linux Cheatsheet



How can I switch CAPS and ESC?

The keymap is defined in /etc/default/keyboard. To switch CAPS and ESC, set the XKBOPTIONS to caps:swapescape.

# KEYBOARD CONFIGURATION FILE

# Consult the keyboard(5) manual page.

XKBMODEL="pc105"
XKBLAYOUT="us"
XKBVARIANT=""
XKBOPTIONS="caps:swapescape"

BACKSPACE="guess" 

To make this change permanent system-wide, open a TTY with CTRL + ALT + F2. Run the following commands.

sudo dpkg-reconfigure keyboard-configuration
setupcon
sudo update-initramfs -u

How can I find the right package that contains some header file?

This can be done with the apt-file tool.

# Install the `apt-file` tool.
sudo apt install apt-file

# Update `apt-get` and `apt-file`.
sudo apt-get update
sudo apt-file update

# Search for the missing header file, e.g. `XRes.h`:
sudo apt-file search XRes.h
# libxres-dev: /usr/include/X11/extensions/XRes.h
# petsc3.15-doc: /usr/share/doc/petsc3.15-doc/html/docs/manualpages/KSP/KSPBCGSLSetXRes.html

I’ve also written apt-search, to search packages.ubuntu.com and parse the HTML.

# Install apt-search
pip install --user apt-search

# Search packages.ubuntu.com for packages that contain the file.
apt-search XRes.h
# libxres-dev: /usr/include/X11/extensions/XRes.h