Sysadmin guides
Linux systems work, measured: systemd, nginx, logrotate, containers, and the command line.
-
Fix UBSan "Signed Integer Overflow" Runtime Errors — and Why the Optimizer Cares
UBSan stops a program with 'runtime error: signed integer overflow' when a signed addition, subtraction, or multiplication produces a value that does not fit in its type. This guide reproduces the message exactly as GCC 13.3.0 prints it, explains why signed overflow is undefined behavior rather than a wrap, shows a loop whose overflow guard the optimizer removes at -O2, and gives the fix that belongs to each case: a wider type, unsigned arithmetic where wrapping is intended, or __builtin_add_overflow where the result has to stay an int.
-
Fix ThreadSanitizer "Data Race" Warnings — Read the Two Stacks, Fix the Shared Variable
ThreadSanitizer prints 'WARNING: ThreadSanitizer: data race' when two threads touch the same variable at the same time and at least one access writes, with no synchronization between them. This guide reproduces the smallest write-write race exactly as GCC 13.3.0 prints it, reads the current and previous access stacks, the location line, and the SUMMARY line, and fixes the race twice: once with a mutex around both accesses, and once by making the shared variable atomic, with the measured exit status for each run.
-
Fix LeakSanitizer "Detected Memory Leaks" — Direct vs Indirect Leaks, Traced to the Owner
LeakSanitizer ends a program with 'detected memory leaks' when heap memory is still allocated at exit and no pointer to it remains. This guide reproduces a direct leak and a linked indirect leak exactly as GCC 13.3.0 prints them, reads the direct and indirect sections and the SUMMARY line, traces each allocation stack to the object that should own the memory, and fixes the leak by giving every allocation an owner, with the measured exit status, the detect_leaks switch, and the suppression form for leaks not yours to fix.
-
Reading an AddressSanitizer Heap-Use-After-Free — Fault, Freed-By, Allocated-By
An AddressSanitizer heap-use-after-free report is the only common sanitizer report with three stacks, and all three earn their place: the fault stack names the line that read through the dangling pointer, the freed-by stack names the line that ended the object's lifetime, and the previously-allocated-by stack names the line that began it. Read together, the three stacks reconstruct the object's whole life and pinpoint the lifetime bug — a use that outlived the delete. This guide frees a heap int and reads it back, reads the full report stack by stack, and fixes the bug by extending the lifetime so the program runs clean under the sanitizer.
-
Reading an AddressSanitizer Heap-Buffer-Overflow — READ vs WRITE, Traced and Fixed
An AddressSanitizer heap-buffer-overflow report looks dense, but three lines in it do most of the work: the access line (WRITE of size 4, or READ of size 4), the fault stack that names the function and line that made the access, and the region line (0 bytes after 16-byte region) that says how far past the allocation the access landed. This guide writes one element past a four-element heap array, reads the full report line by line to the exact index, shows the same bug as a read so the READ and WRITE forms can be compared directly, works out the index arithmetic behind the region line, and fixes the bound so the program runs clean under the sanitizer.
-
Linux Users and Permissions — id, chmod, chown, and sudo
Linux permissions from the ground up: id shows who you are and which groups you belong to, umask sets the starting mode for new files, chmod changes the nine permission bits in numeric or symbolic form, a directory needs execute permission before any file inside it can be opened, and chown changes ownership only with root rights, which is where sudo comes in.
-
Bash Scripting Basics — Variables, Loops, Conditionals, and Functions
Bash scripting from the ground up: a variable holds a value with no spaces around the equals sign, a for loop walks a list, a while loop runs while a test passes, an if branches on a quoted test, and a function takes positional parameters. The guide covers the two beginner traps with exact errors: spaces around the equals sign, and an unquoted variable in a test.
-
Searching, Reading, and Rewriting Text: Twelve Measured Guides
Twelve guides about working with text on the command line: finding lines, reading what is really in a file, and rewriting it, each with a one-line summary and a link to the full guide.
-
Systems and Services: Eight Guides on Limits, Restarts, and Reloads
Eight guides about the systems that run your code: the limits that throttle or kill a process, the restarts that bring a service back, the reloads that swap config without dropping traffic, and the build tools that tax every rebuild.
-
Modern C++ Guides: C++20 and C++23, Built and Run
Nineteen Modern C++ guides — fifteen course guides on C++20 and C++23, plus four measured head-to-heads — each with a one-line summary and a link to the full guide.
-
Measured Comparisons: 9 Guides From November 8, 2026
Nine measured guides published November 8, 2026 — one C++ and eight sysadmin and command-line — each with its headline result and a link to the full table. A companion to the November 9–10 index.
-
Measured Comparisons: 30 Head-to-Head Guides, November 9–10, 2026
Thirty measured head-to-head guides published November 9–10, 2026 — four C++ and twenty-six sysadmin and command-line — each with its headline result and a link to the full table.
-
11 Guides From November 5–8, 2026
Eleven guides published November 5–8, 2026 — Go, Rust, Python, TypeScript, Docker, and Git — each with its own description and a link to the full guide. A companion to the measured-comparisons indexes and the Modern C++ hub.
-
Git Internals: Three Guides That Build the Storage Model by Hand
Three guides that build Git's storage model by hand: loose objects, trees, commits, and packfiles with hand-encoded deltas, in Python and C++, every hash checked against real Git.
-
Copying, Moving, and Splitting Files: Ten Measured Guides
Ten guides about moving data between files: copying, moving, splitting, merging, and comparing, each with a one-line summary and a link to the full guide.
-
Concurrency, Async, and Waiting: Fifteen Guides on Threads, Coroutines, and Waking Up
Fifteen concurrency, async, and waiting guides: threads and synchronization, coroutines, and wake latency, each with a one-line summary and a link to the full guide.
-
Hex-Dumping a 64 MiB Binary, Measured: xxd vs hexdump vs od
Hex-dumping the same 64 MiB binary takes 0.68 seconds with xxd -p and 6.57 with hexdump -C — and default od and hexdump collapse 4,194,304 lines of zeros into 3, while bare hexdump prints byte-swapped word pairs.
-
How Fast Does systemd Restart a Crashed Service? Restart=always vs on-failure, Measured — and the Crash Loop It Refuses
With RestartSec at its 100ms default, systemd takes 0.252 seconds to restart a crashing service, not 0.100 — the delay is a minimum, and systemd adds about 0.15 seconds of its own. on-failure restarts a crashing service exactly like always, and the default start limit stops the loop after 5 restarts.
-
Cutting a Million-Line File Into Ten, Measured: split vs csplit vs awk
Splitting a million-line file into ten chunks takes 0.031 seconds with split and 0.31 with awk — and split -n r/10 scrambles the order, split -b makes an eleventh chunk, and csplit leaves an empty first file when the pattern matches line 1.
-
Copying a Sparse File, Measured: Which Tools Preserve the Holes
Copying a 1 GiB sparse file takes 0.004 seconds with plain cp and 1.7 seconds with plain rsync — and cp keeps the file at 3 MiB on disk while rsync expands it to the full 1 GiB. dd conv=sparse and rsync --sparse preserve the holes at a cost; cat and plain dd fill them.
-
Seeing the Hidden Characters, Measured: cat -A vs sed -n l vs od -c
Seeing the hidden characters in a million-line file takes 0.055 seconds with cat -A and 5.7 with od -c — but cat -v leaves every tab literal, sed -n l folds long lines so a million-line file prints 1,001,020 lines, and default od silently drops 97 lines to star elision.
-
Numbering a Million Lines, Measured: cat -n vs nl vs awk vs grep -n
Numbering a million lines takes 0.077 seconds with cat -n and 0.21 with nl — but nl numbers only 950,000 of the 1,000,000 lines by default, a lone backslash-colon line un-numbers the rest of the file, and nl -ba produces output byte-identical to cat -n at 2.8 times the cost.
-
Finding Lines by Prefix: look vs grep vs rg vs awk vs sed, Measured
Finding 1,000 lines by prefix in a million-line sorted file costs 0.0013 seconds with look, 0.0051 with rg and 0.0088 with grep on util-linux 2.39.3 — but look returns nothing at all on unsorted input, and its -b flag does not exist on Linux.
-
Joining Two Files on a Key: join vs awk, Measured
Merging a million fact rows against a 100,000-key lookup costs 0.07 seconds with join on pre-sorted inputs and 0.46 with an awk hash merge on GNU coreutils 9.4 and gawk 5.2.1 — and even paying for both sorts, join still wins 1.73 times over awk.
-
Wrapping Long Lines, Measured: fold vs fmt vs awk
Wrapping 510,000 lines to 80 columns costs 0.23 seconds with fold and 0.72 with fmt on GNU coreutils 9.4 — fmt is 3.15 times slower and silently joins short lines, while fold cuts a 200-character word in half and fmt refuses to break it at all.
-
Tabs to Spaces and Back, Measured: expand vs unexpand vs sed vs awk vs perl
Converting a million tabbed lines to spaces takes 0.11 seconds with expand and 0.53 with awk — but a naive sed substitution is byte-identical to expand when every tab sits on a tab stop and misaligns 266,335 lines otherwise, and unexpand -t 8 silently converts mid-line blanks exactly like -a.
-
Editing a File In Place, Measured: sed -i vs perl -pi vs awk
Editing a million-line log in place costs 0.18 seconds with sed -i and 0.23 with perl -pi on GNU sed 4.9 and Perl 5.38 — the backup costs nothing, the awk temp-file form costs twice as much, and every one of the six forms replaces the file instead of editing it, breaking symlinks and hard links.
-
Copying a Directory Tree, Measured: cp -a vs rsync -a vs tar-pipe
Copying a 10,000-file tree takes 0.16 seconds with a tar pipe and 0.38 with rsync -a — but on a single 1 GiB file cp -a wins at 0.45 seconds, rsync -a without a trailing slash nests the whole tree one level down, and tar keeps the seconds but not the nanoseconds.
-
Converting CRLF to LF, Measured: tr vs sed vs perl vs awk
Converting a million CRLF lines to LF takes 0.12 seconds with tr and 0.48 with awk — but tr deletes 1,000 carriage returns the other three preserve, sed, perl and awk produce byte-identical output, and awk adds a newline the file never had.
-
Copying a File Without read() and write() Is About Twice as Fast: sendfile vs copy_file_range vs splice, Measured
At 1 GiB, sendfile, copy_file_range, and splice copy a file in 365–467 ms against 854 ms for a read/write loop on median — about twice as fast. At 64 MiB the edge is gone, and at 1 MiB it is noise.