Skip to main content

Chapter 22: Linux Operations for Agent Deployment

Ali built a competitor-analysis agent in Chapters 20 and 21. It scrapes pricing data, stores results in a database, and generates daily summaries. He runs it on his laptop. It works: when his laptop is open.

Sunday night. His biggest client has a board meeting Monday morning. The agent was supposed to generate a weekend pricing report. Ali opens his laptop and checks the dashboard. The agent has not run since Friday. Three days of missing data. Board meeting in twelve hours.

His friend Dev has a cloud server. "I'll give you SSH access," Dev texts. "Get your agent running there and it won't depend on your laptop anymore."

Ali opens a terminal. Types an SSH command. A blinking cursor on a black screen. No desktop. No icons. No file explorer.

This chapter is how Ali, and you: go from that blinking cursor to a production agent that runs 24/7, survives reboots, and recovers from failures. You will not memorize Linux commands. You will direct Claude Code to execute them, read what comes back, and understand what it means.

Chapter Thesis

Your agent's code might be perfect. If you can't deploy it to a server, keep it running, and fix it when it breaks, it's a side project, not a product. Linux operations is the bridge between "it works on my laptop" and "it runs in production."

📚 Teaching Aid

What You'll Learn

By the end of this chapter, Ali's competitor-tracker agent runs as a production systemd service that:

  • Starts automatically when the server boots
  • Restarts automatically if it crashes
  • Logs all activity for monitoring
  • Runs under a dedicated non-root user
  • Accepts connections only via SSH keys
  • Can be diagnosed systematically when problems occur

This is a real deployment, not a toy example.

Prerequisites

Before starting this chapter, you should have completed:

  • Chapter 17: Seven Principles of Agent Work: Especially Principle 1 (Bash is the Key) and Principle 5 (Persisting State in Files)
  • Chapters 19–21: You've built agent workflows for file processing, Python, and SQL

No prior Linux experience is required. Lesson 1 starts from a blinking cursor.

Windows Users

If you're on Windows, you need WSL2 (Windows Subsystem for Linux). Run wsl --install in PowerShell as Administrator, then restart your computer. All commands in this chapter work in WSL2 Ubuntu.

Lessons Overview

LessonTitleDurationFocus
Lesson 1Where Your Agent Lives30 minSSH, filesystem, server orientation
Lesson 2Reading What Your Agent Does30 minCommand output, permissions, vocabulary
Lesson 3Setting Up Your Agent's Home30 minDirectory structure, .env, logs
Lesson 4Making Your Agent Unkillable35 minsystemd services, restart policies
Lesson 5Locking the Door30 minUsers, permissions, SSH keys, security
Lesson 6When Things Go Wrong35 minLNPS triage, log analysis, debugging
Lesson 7Capstone: Zero to Production45 minDeployment spec, full integration
ExercisesLinux Operations Exercises60 minHands-on practice across all lessons
QuizChapter Quiz20 min50-question conceptual assessment

Total: ~5.25 hours (including exercises and quiz)

The Teaching Pattern

Every lesson in this chapter follows the same flow:

  1. Story beat: Ali hits a real problem
  2. Direct Claude Code: You tell the agent what to do in plain English
  3. Read the output: Understand what came back and why
  4. Build the mental model: Connect the output to the concept

You will not type Linux commands from memory. You will direct an agent, watch what it does, and learn to understand the results.

Quick Reference: Linux Terms in Plain English

New to Linux? These 12 terms appear throughout the chapter. Each definition is two sentences maximum.

TermPlain English
ShellThe program that reads your commands and tells the OS to run them. On Linux servers, this is almost always bash.
TerminalThe window application that shows your shell. Terminal is the glass, shell is the voice on the other end.
DirectoryWhat Windows calls a "folder." On Linux, we say "directory": same concept, different word.
RootTwo meanings:/ is the top of the filesystem tree, and root is the superuser account with unlimited power. Context tells you which.
DaemonA service that runs in the background, started at boot, not attached to any terminal. Your agents become daemons in Lesson 4.
PortA numbered channel for network communication. Your agent listens on a specific port (e.g., 8080) for incoming requests.
ProcessAny running program. Your agent is a process with an ID number (PID).
PipeThe | character. Takes the output of one command and feeds it as input to the next.
RedirectSending output to a file (>) instead of the screen. >> appends; > overwrites.
Absolute pathA file address starting from /. Works regardless of where you are (e.g., /var/log/agent.log).
sudo"Run this as root." Grants temporary admin power for one command. Use sparingly; misuse causes real damage.
Environment variableA named value available to all processes in a session. Used for secrets, configuration, and API keys.

Let's Begin

Ali is staring at a blinking cursor on Dev's server. Twelve hours until the board meeting. The agent needs to be running by morning.

Start with Lesson 1: Where Your Agent Lives →