Linux - pdorobisz/cheatsheets GitHub Wiki

Input

Apple keyboard

# use function keys (F1, F2 etc.) instead of media keys:
echo 2 | sudo tee /sys/module/hid_apple/parameters/fnmode

### swap Alt and Cmd keys:
echo 1 | sudo tee  /sys/module/hid_apple/parameters/swap_opt_cmd

To make these changes permanent add them to /etc/modprobe.d/hid_apple.conf:

options hid_apple fnmode=2
options hid_apple swap_opt_cmd=1

and execute:

sudo update-initramfs -u -k all

More info: https://wiki.archlinux.org/index.php/Apple_Keyboard

DNS

By default name resolving is handled by systemd-resolved service. It manages /etc/resolv.conf file (it's a symlink to /run/systemd/resolve/stub-resolv.conf) and runs stub resolver on 127.0.0.53 interface (it's listed as only DNS server). systemd-resolved is configured by NetworkManager when it connects to network and receives DHCP data. To view current configuration run systemd-resolve --status.

Different DNS servers for different domains

Use dnsmasq for resolving names. It can be automatically run and managed by NetworkManager, to enable dnsmmasq plugin:

  1. Add to /etc/NetworkManager/NetworkManager.conf:
[main]
dns=dnsmasq
  1. Configure dnsmasq in /etc/NetworkManager/dnsmasq.d/, e.g.:
# /etc/NetworkManager/dnsmasq.d/00-mydomain.conf
server=/mydomain/10.20.30.40
# /etc/NetworkManager/dnsmasq.d/01-default.conf
server=8.8.8.8
# /etc/NetworkManager/dnsmasq.d/02-add-hosts.conf
# by default dnsmasq plugin doesn't read from /etc/hosts so it has to be manually added
addn-hosts=/etc/hosts
  1. Make /etc/resolv.conf symlink for /run/NetworkManager/resolv.conf

  2. Restart NetworkManager

sudo systemctl stop NetworkManager
sudo systemctl start NetworkManager

Now NetworkManager will start dnsmasq server on 127.0.1.1 interface and configure it via DBus. It will also set 127.0.1.1 as a DNS server in /etc/resolv.conf. This server can be also specified as DNS server in VPN connection's settings if there's a DNS server inside the network you connecting to that should be used only for resolving internal hosts.