book.rymcg.tech

info

This repository contains a collection of books written by EnigmaCurry.

This content is open-source, CC BY 4.0. See LICENSE for attribution rules.

Books

Site features

This website is presented as a book of books, so you can read everything from beginning to end. There are two ways to flip through the pages:

  • Press the keyboard left and right arrow keys.
  • Click the arrow buttons in the top right corner of every page (handy on a touch screen).
Keyboard navigation
previous page
next page
Page-turn buttons
previous page
outline of this page
next page

Table of contents

The menu on the left lists every book on the site, with the book titles as the top level headings. On smaller screens the menu is hidden; tap the circle button in the top left corner to slide it open.

Menu button (small screens only)
show / hide the menu

Every page also has its own outline. Click the # button in the top right corner to jump between the headings of the page you are reading.

Page outline
headings on this page

Theme

This website has a custom terminal theme with four colour palettes: amber, green, mono, and lite. By default it follows your operating system’s light or dark mode preference (lite for light, green for dark). You can switch palettes — and toggle the terminal effects — from the controls in the lower left menu, below the table of contents.

Change theme
theme:
cycle the colour palette
fx:
toggle terminal effects

Blocks

Shell command blocks

Throughout these books, you will find literal command blocks that you should copy and paste to run in your Bash shell.

Commands that are to be run on your primary workstation are in blue:

[bash]: Run this on your workstation:
whoami
hostname

Each code block is intended to be run as a whole (don’t copy individual lines). Click the copy button in the top right corner of any code block — like the blue block above — to copy the whole thing to your clipboard.

Paste the copied command block into your terminal, edit it as necessary, and then press Enter to run it.

You will also sometimes see the example output that a command prints:

(stdout)
ryan
toolbox

Pay attention to the color and the title of the box to provide important context. Commands that are to be run on a different machine, or in a container, etc. are usually orange:

Run this inside the container foo:
whoami
hostname
(stdout)
root
foo

Config blocks

Temporary shell variables are used to carry common config values across multiple command blocks. You can copy and paste them just like you do when running a command, but they are used only for configuration before running another command:

[bash]: Set temporary environment variables
COLOR=orange
FOOD="milk chocolate covered raisins"

Subsequent code blocks can reference these temporary variables:

[bash]: Run this on your workstation:
echo "Favorite color : ${COLOR}"
echo "Favorite food  : ${FOOD}"
(stdout)
Favorite color : orange
Favorite food  : milk chocolate covered raisins

Edit file blocks

Sometimes it’s easiest to edit a file by hand. These green blocks invite you to edit the given file, with your preferred text editor:

Edit this file: /tmp/foo.txt
this text goes into /tmp/foo.txt

Use Bash 5.1+

[bash]: Run this on your workstation:
$ bash --version | head -1
(stdout)
GNU bash, version 5.2.26(1)-release

The commands written in this book are tested with Bash version 5.2:

Bracketed Paste

Since Bash 5.1, an important feature has been turned on by default: bracketed paste. This lets you copy and paste multi-line commands, from this web page, into your terminal, and edit the entire command directly on the command line, before anything is run. It gives you a chance to read, and edit, the entire command block that you paste, to be sure its all correct, before you run it. When you’re ready, you press the Enter key, and then the whole block is run. To cancel, press Ctrl-C.

  • When you paste a block into Bash, it is automatically highlighted in inverse color. This should indicate to you that the command has not yet been run.
  • You can edit the entire multiline code block, but you need to be careful, do not press the up or down arrow keys, because this will cancel the command and begin searching your command history instead.
  • Use the linear left/right movement keys for readline mode:
    • Left / Right arrow keys to move the cursor one character at a time.
    • Ctrl + Left/Right arrow keys, move by words at a time.
    • Ctrl-A moves the cursor to the very beginning of the block.
    • Ctrl-E moves the cursor to the very end of the block.
    • Ctrl-K will “kill” the text after the cursor.
    • To cancel the command before running it, press Ctrl-C.
    • To run the reviewed command, press Enter.

Before Bash 5.1, unless you specifically turned this feature on, commands that you paste would be run immediately, which is such an insecure anti-feature for a default setting!

warning

If you need to be running an old version of Bash, you should at least turn on bracketed paste:

[bash]: Run this on your workstation:
## Only necessary for Bash < 5.1:
echo "bind 'set enable-bracketed-paste on'" >> ~/.bashrc
bind 'set enable-bracketed-paste on'
// settings
theme:
fx: