Linux 102


layout: cover kicker: Living on the command line · Part two title: Linux 102 subtitle: Processes, tmux, scripting, and remote work


layout: statement kicker: Where 101 left off title: 101 was about getting around. 102 is about staying in control — long-running work, remote boxes, and automating the boring parts.


layout: agenda title: What we'll cover items:



layout: section index: "01" kicker: Part one title: Processes & signals


layout: default kicker: Foreground vs background title: Stop blocking your terminal

A command normally holds your shell until it finishes. You don't have to wait:

Ctrl+Z suspends whatever's running — then bg resumes it in the background. fg brings it back.


layout: define kicker: Don't lose work to a disconnect term: nohup & disown definition: A background job still dies when the shell closes. nohup (or disown) cuts that cord so it keeps running after you log out. points:



layout: reference kicker: Find it, then signal it title: Killing processes properly groups:



layout: statement kicker: The rule title: Always try kill first. Reach for -9 only when it ignores you — it can't clean up after itself.


layout: section index: "02" kicker: Part two title: tmux


layout: define kicker: The remote-work superpower term: tmux definition: A terminal multiplexer — your session lives on the server, not in your SSH connection. Drop wifi, close the laptop, reconnect later: it's all still there. points:



layout: reference kicker: The 20% you'll use daily title: tmux essentials — prefix is Ctrl+B, then a key groups:



layout: default kicker: The typical flow title: Start a job, walk away, come back


layout: section index: "03" kicker: Part three title: Shell power


layout: reference kicker: Stop retyping title: History & expansion items:



layout: code-explain kicker: Joining commands title: Chaining, substitution, and a better tee notes:


make && ./run            # run only if the build passed
ping -c1 host || echo "down"   # fallback on failure
echo "today is $(date +%F)"    # inline command output
diff <(sort a.txt) <(sort b.txt)   # compare without temp files

layout: default kicker: Make it yours title: Aliases & functions

Stop typing the same things. Put these in your ~/.zshrc (or ~/.bashrc):

alias gs='git status'
alias ll='ls -lah'

# a function when you need arguments
mkcd() { mkdir -p "$1" && cd "$1"; }

After editing, run source ~/.zshrc (or open a new shell) to load the changes.


layout: section index: "04" kicker: Part four title: Scripting


layout: code-explain kicker: Anatomy of a script title: From one-liner to something you trust notes:


#!/usr/bin/env bash
set -euo pipefail

dir=${1:?usage: backup.sh DIR}
for f in "$dir"/*.log; do
  echo "archiving $f"
done

layout: reference kicker: Control flow title: Tests, loops, conditionals groups:



layout: statement kicker: Know when to stop title: Past ~50 lines, or once you need arrays and real data — switch to Python. Bash is glue, not a language to live in.


layout: section index: "05" kicker: Part five title: Networking & remote


layout: reference kicker: What's happening on this box? title: Inspect the network items:



layout: code-explain kicker: SSH is more than a login title: Tunnels — reach things you otherwise can't notes:


# the remote Postgres, as if it were local:
ssh -L 5432:localhost:5432 devbox
#   psql -h localhost   → hits the server's DB

# expose your local app to the remote box:
ssh -R 8080:localhost:3000 devbox

layout: default kicker: Move files like a pro title: rsync — copy only what changed

rsync -avz src/ user@host:/backup/   # sync a dir to a server (over SSH)
rsync -avz --delete src/ dst/        # mirror exactly — removes extras
rsync -avzP big.iso host:/tmp/       # resumable, with a progress bar

Unlike scp, rsync skips unchanged files and can resume — re-running a big transfer is nearly instant.


layout: section index: "06" kicker: Part six title: Services & scheduling


layout: reference kicker: Long-running services title: systemd & logs groups:



layout: default kicker: Run it on a schedule title: cron — set it and forget it

crontab -e to edit, crontab -l to list. Five time fields, then the command:

# ┌ min  ┌ hour  ┌ day  ┌ month  ┌ weekday
  0      3       *      *        *      /home/cagdas/backup.sh   # daily 03:00
  */15   *       *      *        *      /home/cagdas/health.sh   # every 15 min

On systemd boxes, systemd timers are the modern alternative — they log to journalctl and handle missed runs.


layout: reference kicker: The last mile title: Archives, links & disk items:



layout: statement kicker: The through-line title: Your shell is a programmable environment, not just a prompt. The more you automate, the less you retype.


layout: end title: That's 102 subtitle: Set up tmux and one alias today. Write one real script this week.