Introduction

Build the Tools You Use Every Day

Every command you ran in the Linux course — cat, grep, wc, head, tail, tr, uniq — is a C program. These programs are part of the GNU coreutils package, and they have been powering Unix systems for decades.

This course asks one question: can you build them yourself?

Each lesson gives you a coreutils command and asks you to implement its core logic as a C function. Not the full command with every flag and edge case — just the essential algorithm.

  • cat → print a string character by character
  • wc -l → count newlines
  • grep → find lines containing a substring
  • tail → print the last N lines
  • tac → print lines in reverse order

Simple descriptions. Interesting implementations.

Why This Matters

Writing these tools from scratch forces you to think about problems that are usually hidden:

  • How does wc -w know where one word ends and another begins? A state machine.
  • How does tail know where the last N lines start without reading the file twice? Scanning backwards.
  • How does grep check every position in a line? A nested loop over all starting positions.

These are real algorithms running on millions of machines every day. You will understand them after implementing them.

The Connection

This course is designed to follow the Linux and C courses on this platform:

  • The Linux course taught you to use these commands from the shell.
  • The C course taught you the language they are written in.
  • This course connects both: rewrite the commands in C.

What You Will Learn

This course contains 13 lessons organized into 4 chapters:

  1. Output -- echo, cat, rev. Print strings, character by character, and reversed.
  2. Counting -- wc -c, wc -l, wc -w. Count characters, lines, and words using pointer arithmetic and state machines.
  3. Filtering -- head, tail, grep. Select lines from the start, end, or by pattern.
  4. Transformation -- toupper, tr, uniq, tac. Modify and reorder text.

Each lesson explains the command, walks through the algorithm, and gives you a C function to implement and test.

Let's build coreutils.

Next →