# Automation
**Restart `nginx` when a server configuration is modified:**
```shell
$ find /etc/nginx/sites-enabled/ | entr -s 'nginx -s reload'
```
**Run a command when a file in a directory is modified:**
```shell
$ find [directory] | entr -s 'command'
```
**Run a command when a file tracked by `git` is modified:**
```shell
$ git ls-files -m | entr -s 'command'
```
# Disks
**List the detected block devices and their identifiers:**
```bash
$ blkid
```
**Mount an ISO file:**
```bash
$ mount <iso image> <mountpoint> -o loop
```
# Documents
**Merging multiple PDF documents into a single PDF document:**
```bash
$ pdfunite <file 1> <file 2> <output pdf>
```
# File Management
**Copying files from one directory to another but better:**
```sh
$ rsync -ahr --progress --info=progress2 --ignore-existing <source directory> <destination directory>
```
**Remove cached packages from `pacman`:**
```bash
$ sudo pacman -Scc
```
# Git
**Run a `git` command as if you were in a directory:**
```shell
$ git -C <file path> <action> <arguments>
```
**Push an empty git commit:**
```bash
$ git commit --allow-empty -m "<message>"
$ git push
```
# Openbox
**Reload Openbox with an updated configuration without closing and reopening it:**
```bash
$ openbox --restart
```
# Media
**Playing a YouTube video through the command line:**
```bash
$ yt-dlp -o - '<video URL>' | ffplay -
```
```bash
$ mpv '<video URL>'
```
# SSH
**Generate a new SSH key:**
```bash
$ ssh-keygen
```
**Copy your SSH key to the home directory of a user on another server (to enable password-less authentication):**
```bash
$ ssh-copy-id <user>@<server address>
```
**Edit a file stored on a server with Vim:**
```
$ vim scp://<user>@<server address>/<full path>
```
# Text Manipulation
**Return one copy of each line in a file:**
```bash
$ awk '!seen[$0]++' [file]
```
**Return one copy of each line in a file in sorted order:**
```bash
$ sort [file] | uniq
```
# User Management
**Delete a user and their home directory:**
```bash
$ sudo deluser --remove-home <user>
```
**Delete a user and all files which are owned by that user (including on every mounted block device):**
```bash
$ sudo deluser --remove-all-files <user>
```
# Virtual Machines
**Write a qcow2 image to a block device (like a physical drive):**
```bash
$ sudo qemu-img convert -f qcow2 -O raw <qcow2 image> <block device>
```
# X
**Change the keyboard layout to the United States International layout:**
```bash
$ setxkbmap -layout us -variant intl
```
**Load changes you've made to the `~/.Xresources` file:**
```bash
$ xrdb -merge ~/.Xresources
```
## Monitor Configuration
**Show the current state of the display outputs:**
```bash
$ xrandr
```
**Duplicate laptop display to another monitor:**
```bash
$ xrandr --output HDMI-A-0 --mode 1920x1080
```
**Extend the display to another monitor:**
```bash
$ xrandr --output HDMI-A-0 --mode 1920x1080 --above/--below/--left-of/--right-of eDP-1
```
**Reset the configuration for external displays:**
```bash
$ xrandr -s 0
```