Build your own Shell
A Unix shell that reads a command line, runs programs, and wires up pipes and redirection.
- Intermediate
- About 8–16 h
- 5 checkpoints
- 4 tutorials · C, Rust
Pick a tutorial, then check yourself at each checkpoint. Work in any language you like.
Choose a tutorialWhy build it
Every terminal session runs through fork, exec and wait. Writing the loop yourself shows how processes are created, how file descriptors are inherited, and why cd has to be a built-in.
You will be able to
- Create processes with fork and exec (or your language's spawn API) and reap them with wait.
- Explain how file-descriptor inheritance makes pipes and redirection work.
- Tell built-ins from external programs and say why cd and exit must be built-ins.
- Handle signals so that Ctrl-C stops the running program, not the shell.
Skills it exercises
- C for Systems Programming
- Processes & Threads
- Kernel & System Calls
- Advanced Shell & Text Processing
- Linux CLI
Recommended on DevOps Engineer and Operating Systems & Linux.
How you know you are there
Work in any language. Each checkpoint ends with something you can run or observe, so you can check it yourself.
- Checkpoint 1Self-check
Read-eval loop
Done when: The shell prints a prompt, splits the line into words, runs
ls -l /tmp, waits for it and prompts again; Ctrl-D exits cleanly. - Checkpoint 2Self-check
Built-ins
Done when:
cd,pwdandexitwork as built-ins,cdwith no argument goes to $HOME, and an unknown command prints an error without ending the shell. - Checkpoint 3Self-check
Redirection
Done when:
sort < in.txt > out.txtandcmd 2> err.logproduce the same files as bash on the same input. - Checkpoint 4Self-check
Pipelines
Done when:
cat words.txt | sort | uniq -c | sort -nr | head -3matches bash, andpsshows no zombie processes afterwards. - Checkpoint 5Self-check
Signals and exit status
Done when: Ctrl-C interrupts a running
sleep 30but not the shell, and the last exit status is available (as$?or similar).
Stretch goals
- Job control:
&,jobs,fgandbg. - Quoting and environment-variable expansion.
- A test script that compares your shell's output with bash for 20 command lines.
Step-by-step guides
Pick one in a language you know (tutorial languages: C, Rust). They open on the author’s site.
- C
Tutorial - Write a Shell in C(external site)
The shortest path to a working loop. It has no pipes or redirection, so those milestones are yours to add.
- C
Writing a UNIX Shell(external site)
Goes further into signals and process groups.
- C
Build Your Own Shell(external site)
Workshop format with a test suite for each stage.
- Rust
Build Your Own Shell using Rust(external site)
Rust version, including pipes.
Where to go next
- Build your own Container Runtime
Advanced · 12–24 h
Practice builds are self-paced: Tech Atlas does not track them or count them as evidence. To show a skill, take its knowledge check from the skill page.
Tutorials come from codecrafters-io/build-your-own-x (CC0, snapshot of 2026-07-14, commit aa17439; links checked on 2026-10-19). Each tutorial belongs to its author and keeps its own licence; Tech Atlas links to it and does not host it. Briefs, checkpoints and the mapping to skills are Tech Atlas editorial drafts.