How To Learn Linux From Scratch

How To Learn Linux From Scratch

Reading time1 min
#Linux#Technology#Programming#LinuxTutorial#LinuxBeginner#Shell

Mastering Linux from Scratch: A Practical Roadmap

Despite misconceptions, Linux isn’t inherently difficult—just unfamiliar. Industry infrastructure relies on it, from Kubernetes control planes (Linux-only) to embedded IoT hardware. Early hands-on usage delivers more value than overstudying theory.

What is "Linux"?

Three layers to keep straight:

  • Kernel (e.g., v5.15.0): Manages hardware abstraction, system calls, process scheduling.
  • Distribution (Ubuntu 22.04 LTS, Fedora 39, Debian 12): Kernel + userland utilities, service managers, security defaults.
  • User Interface (GNOME, Xfce, CLI shells like Bash or Zsh): Human interaction point—swap GNOME for i3 if you prefer tiling.

Note: Arguments about “pure” distros (e.g., Arch vs. Ubuntu) persist. For learning, stability and documentation beat minimalism.


Step 1: Select—And Isolate—Your First Distro

Rolling releases are tempting; for most, start with Ubuntu LTS or Linux Mint 21.x. Avoid frustration due to constant upstream package churn.

Recommendation:
Spin up a VirtualBox VM (4 GB RAM, 25 GB disk). Snapshots prevent irreversible mistakes. Alternatively, a live USB boots safely on real hardware:

$ sudo dd if=ubuntu-22.04.4-desktop-amd64.iso of=/dev/sdX bs=4M status=progress

Replace /dev/sdX exactly—missteps here overwrite the wrong disk. Always confirm with lsblk.


Step 2: Shell Fundamentals—Hands Dirty Early

Default terminal: Bash (echo $SHELL). Fish and Zsh exist, not essential now.

Common file operations:

ls -lha        # Human-readable, shows hidden files
cd /tmp        # Enter /tmp
pwd            # Show current path
mkdir -p proj/demo
rm -rf demo    # Fully recursive, caution—no “Recycle Bin”
cp file{1,2}.txt ./backup/

Want to find a file by partial name under /etc?

find /etc -iname "*net*"

Gotcha: Use tab-completion to avoid typos and discover available files/commands. Power users chain commands with | and && to automate common sequences.


Step 3: File Permissions—Security Is Default

Most new scripts fail with Permission denied. Linux security isn’t an add-on.

ls -l hello.sh
# -rw-r--r-- 1 alice devops 12 Jun 13 10:32 hello.sh

Three sets: user/group/other. Adjust with chmod (permissions) and chown (ownership):

chmod u+x hello.sh         # Add execute for owner only
chown root:root hello.sh   # Assign to root, useful for scripts in /usr/local/bin

Tip: Avoid chmod 777. It’s the Windows “Everyone/Full Control” equivalent—almost never appropriate in production.


Step 4: Package Management—Idempotent Installs

Each family has its own system. Practice with text editors to observe the mechanics.

Debian/Ubuntu:

sudo apt update
sudo apt install -y vim
sudo apt remove nano

Fedora/RHEL:

sudo dnf install vim

Note: Omit sudo in container or Docker images.
Non-obvious: apt-cache search finds packages by substring. Watch for package locks:

E: Could not get lock /var/lib/dpkg/lock-frontend

Resolve: ensure no other package manager process is running.


Step 5: Automate with Shell Scripts

Real-world: Repetitive CLI sequences (backups, deployments) get old fast.

Example script to back up /etc:

#!/bin/bash
set -e
DATE=$(date +%F)
tar czf /tmp/etc-backup-$DATE.tgz /etc

Mark executable, test, then inspect with tar tzf /tmp/etc-backup-*.tgz | head.

Non-obvious tip: set -e halts script on error—preventing silent data loss.


Step 6: Built-in Documentation—First Resort

Manuals are often more current than online blogs.

  • man grep – exhaustive, sometimes dense.
  • <cmd> --help – quick flags list.
  • info coreutils – GNU verbose docs, useful for deep dives.

Example: misunderstanding rm flags will cost you. --no-preserve-root disables safety checks:

sudo rm -rf /
# Don't.

Tip: Search inside manpages with /pattern (e.g., /owner).


Step 7: Build and Break Deliberately

Set up a small project:

  • Write a hello-world.sh that reads your username from $USER.
  • Use crontab -e to schedule it.
  • Intentionally misconfigure (e.g., typo in shebang), read resulting error (bad interpreter: No such file or directory), and fix.

Most learning occurs through breakage and repair, not passive reading.


Resources and Community

  1. The Linux Documentation Project
  2. Arch Wiki—unmatched depth, even for non-Arch users.
  3. Forums: Stack Overflow, Server Fault, and distribution-specific boards.
  4. #linux IRC and Matrix channels—answers often come with “RTFM”. Read the fine manual.

Side Notes from Experience

  • GUI tools (e.g., GNOME Disks, Software Center) lower the barrier but obscure what's actually happening—use sparingly.
  • Bash sessions break (e.g., zombie terminals, odd env vars). reset often restores sanity.
  • An unconfigured firewall (e.g., ufw status) is a silent risk. Review defaults post-install.

Linux proficiency is cumulative—acquired by navigating real failures, reading terse logs, and discovering the unexpected utility of arcane flags. If an official source contradicts lived experience, test on a VM. The only real mistake is never making any.