Building from Source

Building from Source

Concepts

Why Build from Source?

Occasionally you need to compile software yourself:

  • The package is not available in any repository, Snap, or Flatpak
  • You need a newer version than what is available
  • You need to enable specific compile-time options
  • You are developing or patching the software
  • You are autistic

Building from source means downloading the program’s source code and compiling it into a binary executable on your machine.

[Read more]

Building Your Environment

Building Your Environment

This capstone lesson ties everything together. You will build a complete power-user Linux environment from scratch — dotfiles, tools, shell configuration, SSH keys, tmux, firewall, backups, and scheduled tasks. Each section references the module where the concept was taught.

This is a guided project, not a copy-paste exercise. Adapt every step to your preferences.


Part 1: Essential Tools

References: Module 04 — Package Management

Install the tools you will use throughout:

[Read more]

Conditionals

Conditionals

Concepts

The if Statement

if condition; then
    commands
fi
if condition; then
    commands
elif other_condition; then
    other_commands
else
    fallback_commands
fi

Example:

if [ -f /etc/hosts ]; then
    echo "/etc/hosts exists"
else
    echo "/etc/hosts not found"
fi

Test Commands: [ ] vs [[ ]]

There are two ways to write conditions:

[ ] — POSIX Test (compatible with sh)

if [ "$a" = "$b" ]; then ...

[ is actually a command (try which [). It requires:

  • Spaces after [ and before ]
  • Quoting variables (unquoted empty variables cause syntax errors)
  • Escaping < and > operators

[[ ]] — Bash Extended Test (preferred)

if [[ "$a" == "$b" ]]; then ...

[[ is a Bash built-in with advantages:

[Read more]

File Operations

File Operations

Concepts

Creating Files and Directories

touch — Create an Empty File (or Update Timestamp)

touch newfile.txt           # creates newfile.txt (empty)
touch file1.txt file2.txt   # creates multiple files at once
touch existing.txt          # if file exists, updates its modification timestamp

touch does not overwrite an existing file’s content — it only updates the timestamp.

mkdir — Make Directories

mkdir myfolder              # create a directory
mkdir dir1 dir2 dir3        # create multiple directories
mkdir -p a/b/c              # create nested directories (creates a, a/b, and a/b/c)

The -p flag is important: without it, mkdir a/b/c fails if a/ or a/b/ do not already exist. With -p, it creates the entire chain.

[Read more]

File Permissions

File Permissions

Concepts

Why Permissions Matter

Linux is a multi-user operating system. Multiple users can have accounts on the same machine. Permissions control:

  • Who can read a file
  • Who can modify a file
  • Who can run a program

Without permissions, any user could read your private documents, modify system configuration, or delete other users’ files.

Please note that a user does not necessarily need to be a human!

The Permission Model

Every file and directory has three sets of permissions for three classes of users:

[Read more]