This chapter covers terminal navigation, file manipulation, pipelines, and process control. All of these work identically on any Unix-like system.
Environment tier: any — macOS, Linux, or Windows via WSL
all work for everything in this chapter.
Windows
Install WSL 2[1]. Open the Microsoft Store, search for Ubuntu[2], and install it. Once installed, open the Ubuntu app. The prompt that appears is a Linux Bash shell running inside a real Linux kernel. Every command in this chapter runs there without modification.
macOS
Terminal.app or iTerm2 work for this chapter. macOS defaults to zsh,
but Bash is still installed at /bin/bash. Most commands in f01 are
identical in either shell — but the environment and shell scripting
pages use ~/.bashrc and #!/bin/bash, which are Bash-specific.
The simplest path: open your terminal and run bash. You are now in a
Bash session and everything in this chapter works as written.
If you prefer to stay in zsh, use ~/.zshrc instead of ~/.bashrc
and #!/bin/zsh in your shebangs. The concepts are identical; only
the file names differ.
One note: later chapters (from f04 onward) require Linux-specific features that do not work on macOS natively. From f04 onward, this chapter's approach no longer applies — some chapters require GCC, Linux syscalls, or platform-specific toolchains that diverge on macOS (Darwin). The easiest path forward on Mac is a Linux VM via UTM[3] with Ubuntu. You do not need to set that up now.
The final page of this chapter installs NetHack. On macOS:
brew install nethack if you have Homebrew, or use your Linux VM —
which is a good excuse to set it up before f04.
Linux
Open a terminal. You are already there.
Verify
Run these two commands:
echo $SHELL
uname -secho $SHELL prints your shell path — something like /bin/bash or
/usr/bin/zsh. uname -s prints the kernel name. On Linux (including
WSL) it prints Linux. On macOS it prints Darwin. Either is
acceptable for this chapter.
If uname -s prints Linux, you are ready for every chapter in the
curriculum. If it prints Darwin, you are ready for f01 and f02 — set
up a Linux VM before you reach f04.
Compatibility notes
sed -i
sed -i works differently on GNU sed (Linux, WSL) and BSD sed
(macOS):
# GNU sed — Linux and WSL
sed -i 's/old/new/' file
# BSD sed — macOS
sed -i '' 's/old/new/' fileBSD sed requires an explicit extension argument after -i. An empty
string ('') means edit in place without a backup — the same result
as GNU sed -i. If you are following this chapter on macOS, use the
BSD form wherever sed -i appears.