/user/kayd @ devops :~$ ls ~/series/linux-commands-to-go/

series · 17 articles · 94k words

Linux Commands to Go

Seventeen tutorials that start with the Linux command you would actually type and end with a Go program that does the same job properly — monitoring, logs, deploys, CI, and AWS.

Every article here has the same shape. It opens with the command you would actually type — lscpu, curl, ps, grep, envsubst, aws s3 ls — and it closes with a Go program that does the same job in a way you could put on a server and leave running.

That order is the whole point, and it is not the order most tutorials use.

Why start with the command

The command is the fastest way to learn what the data looks like. Before you can write a program that reports CPU usage, you need to know that Linux does not have a “CPU usage” number anywhere — it has a file, /proc/stat, full of counters that only ever go up. You find that out in about forty seconds with cat. You find it out in about two hours if you start by opening an editor.

So the first half of each article is spent in the shell, on purpose, until the concept is concrete and you have seen the actual bytes.

Why not stop there

Because the shell version is a demo, and you will find out where it stops the hard way. Three examples, all of them from articles in this series:

  • It is fine until it has to be a number. grep will find the slow requests in an nginx log. It will not give you the 95th percentile, and the awk one-liner that does is write-only by the third field.
  • It is fine until there is more than one of something. A for host in ...; do ssh ...; done loop is a perfectly good deploy script for three servers. At thirty it is a fifteen-minute deploy where one host failed and you cannot tell which, because the output of thirty SSH sessions arrived interleaved.
  • It is fine until it has to be right. Reading /proc/stat once gives you the average CPU usage since the machine booted, which is a number that looks plausible and is useless. You need two reads and the difference between them. The CPU article walks into that wall deliberately, then fixes it.

The Go half is not there because Go is fashionable. It is there because a single static binary with no runtime, no dependency tree, and real error handling is the thing you can copy onto a server and trust — and because writing it forces you to answer the questions the command was quietly answering for you.

The five ideas that keep coming back

Read three or four of these and you will notice the same handful of problems wearing different clothes. They are the actual curriculum:

The kernel talks to you in text. /proc/stat, /proc/meminfo, /proc/<pid>/status — CPU monitoring, process management, and health checks all end up reading the same pseudo-filesystem. Once you have parsed one of these you have parsed all of them.

Counters are cumulative; you want deltas. Almost every metric Linux exposes is a number since boot. Sample it twice, subtract, divide by the interval. Miss this and your dashboard confidently displays the wrong thing forever, which is worse than displaying nothing.

Parsing is where the bugs live. Not the network code, not the concurrency — the parsing. A timestamp that is ambiguous twice a year when the clocks go back. An nginx log line with a space inside a quoted field. A sudoers file with an #includedir in it. The interesting failures in this series are nearly all somebody’s text format meeting reality.

Do it to one thing, then do it to N things. Every tool here has a step where it stops handling one server and starts handling a list of them, and the step after that is always about the failure modes that only appear at N: one host hanging forever, partial success, output that has to stay attributable to the host it came from.

“Failed” needs a definition. Exit codes, signals, HTTP status, a health check that is neither up nor down. The deploy tool needs to decide what triggers a rollback. The supervisor needs to decide what counts as a crash worth restarting. Getting this wrong is how you build something that restarts a healthy process in a loop.

How to read this

Not in order. These were written as independent articles over about four years, and none of them assumes you have read another. Pick the one that matches a problem you currently have — that is the version of this you will actually finish.

If you want a route anyway:

  • Shortest way in: Master tmux. Small, immediately useful, and the Go part is a thin CLI over commands you already ran by hand.
  • The series in miniature: CPU Monitoring. Two commands, a wrong answer, the reason it is wrong, and the fix. If you only read one, read this one.
  • The one that changes how you work: Deployment Automation, because rollback and parallelism are where hand-rolled deploy scripts stop being adequate.

What you need

A Linux or macOS shell, and Go 1.21 or newer. A few articles want Docker (container logs, nginx logs) and two want an AWS account with credentials configured — the free tier covers everything they do. No Kubernetes anywhere in the series. No framework. The Go programs use the standard library and, where a cloud API is involved, that vendor’s SDK; nothing else.

Every article is self-contained: the code is complete rather than elided, and it is built up a step at a time so you can stop at any point and still have something that runs.

What this does not cover

There is no Kubernetes, no service mesh, no Terraform here — those live elsewhere on this site. This series is deliberately about the layer underneath: the commands on the box, the files they read, and what it takes to turn one into a program you would leave running.

All 17 articles

The machine in front of you

One host, and the four things you end up doing on it at 2am: attaching to a session, finding out what is eating the CPU, killing the right process, and working out who is allowed to do what.

  1. Master tmux: From Multiplexer to a Go Session Manager Learn tmux from scratch — sessions, windows, panes, and scripting — then build a Go CLI tool that launches your dev environment from a YAML config. 15 min read · Feb 2026
  2. CPU Monitoring: From Linux Commands to a Go Dashboard Learn CPU monitoring step by step: start with lscpu and nproc, then build a Go tool that reads /proc/stat, fixes the jiffies delta, and shows a live dashboard. 20 min read · Feb 2026
  3. Process Management: From Linux Commands to a Go Supervisor Learn process management step by step: start with ps, kill, and systemctl, then build a Go supervisor that sends signals, manages children, and auto-restarts. 25 min read · Feb 2026
  4. Linux Access Control: From sudo to a Go Security Scanner Learn Linux access control step by step: start with sudo and file permissions, then build a Go scanner that parses /etc/sudoers and flags dangerous configs. 42 min read · Feb 2026

Logs, and the text they hide

Every one of these starts as a grep and ends as a parser, because the moment you want a number out of a log file rather than a line, grep has run out.

  1. Nginx Log Analysis: From grep to a Go Log Parser Learn nginx log analysis step by step: start with grep and awk one-liners, then build a Go parser that finds slow endpoints and detects error spikes. 29 min read · Feb 2026
  2. Docker Logs: From docker logs to a Go Log Collector Learn Docker logging from the ground up: start with docker logs and drivers, then build a Go collector that tails, parses, and aggregates container logs. 34 min read · Sep 2023
  3. Timezones in Production: From Linux Commands to Go Learn timezone handling step by step: start with date and timedatectl, then build a Go log timestamp normalizer, hit the DST bug, and add multi-zone monitoring. 17 min read · Feb 2026

More than one machine

The shell loop over a list of hosts works until one host is slow, one is down, and you cannot tell which. This is where Go starts paying for itself.

  1. Remote Server Config: From SSH Loops to a Go Config Tool Learn remote server config from scratch: start with SSH loops and bash, then build a Go tool that connects to many servers, pushes configs, and checks services. 34 min read · Nov 2022
  2. Deployment Automation: From SSH Scripts to a Go Deploy Tool Learn deployment automation from scratch: start with SSH, rsync, and shell scripts, then build a Go tool with health checks, rollbacks, and parallel execution. 28 min read · Jan 2025
  3. Service Health Checks: From curl to a Go Health Monitor Learn service health monitoring from scratch: start with curl, ping, and /proc, then build a Go monitor that checks HTTP, TCP, and disk, and alerts on failures. 27 min read · Aug 2023

Build, ship, schedule

The plumbing that runs without you: hooks that fire on a commit, a runner that reacts to a push, a scheduler that survives a reboot, and the config files all of it needs.

  1. Git Hooks: From Shell Scripts to a Go Webhook Server Learn Git automation from scratch: start with shell pre-commit and pre-push hooks, then build a Go webhook server that listens for pushes and triggers builds. 29 min read · Nov 2022
  2. CI Pipeline Basics: From Shell Scripts to a Go Build Runner Learn CI pipeline fundamentals from scratch: start with shell scripts that run tests, then build a Go CI runner that watches repos and reports build results. 30 min read · Aug 2023
  3. Linux Automation Tools: From Cron to a Custom Go Runner Compare the major Linux automation tools — cron, at, make, systemd timers — then build a custom Go task runner with scheduling, retries, and a status dashboard. 30 min read · Feb 2025
  4. Config Templating: From envsubst to Go Learn config templating step by step: start with envsubst for variable substitution, then build a Go multi-environment generator with conditionals and defaults. 21 min read · Feb 2026

AWS from the command line

Same idea, one layer up: the AWS CLI teaches you the shape of the API, then the SDK does the part the CLI makes painful — pagination, retries, and joining two calls together.

  1. AWS CLI Automation: From Bash Scripts to Go Learn AWS automation step by step: start with AWS CLI for S3, EC2, and IAM, then build the same in Go with the AWS SDK, ending with an infrastructure report. 21 min read · Feb 2026
  2. AWS Security Audit: From AWS CLI to a Go Security Scanner Learn AWS security auditing from scratch: use the AWS CLI to check IAM, security groups, and S3 policies, then build a Go scanner that finds misconfigurations. 33 min read · Mar 2024

And one that runs the other way

The odd one out, and worth reading for it: instead of starting at a command it starts at a raw TCP socket and builds up to the service.

  1. Building a URL Shortener in Go: From TCP Sockets to a Working Service Build a URL shortener in Go from raw TCP up: routing, short codes, persistence, redirects, click analytics and rate limiting, with the real bugs left in. 16 min read · Aug 2023

Get new articles by email

One DevOps article a week, plus the 18-cheatsheet PDF pack. No spam, one click to leave.