Chapter 01
Your machine
Getting a Unix shell, a package manager, Git and an editor working, and the words for the parts you are using.
WSL 2
Also called Windows Subsystem for Linux
- What
- A Windows feature that runs a real Linux distribution, Ubuntu by default, in a lightweight virtual machine with a real Linux kernel. You get a normal Bash shell and Linux tools without dual booting.
- Why
- Servers, containers and most tutorials assume Linux. WSL lets you learn and work in that environment while keeping Windows for everything else.
wsl --install
wsl -l -v
wsl --install -d Debian
wsl --updateWatch out
Mixing up the shells: these commands run in PowerShell, while everything else in this sheet runs inside Ubuntu.
Windows Terminal
- What
- Microsoft's terminal app with tabs, split panes and a profile for each shell, including every WSL distribution.
- Why
- Setting the Ubuntu profile as the default, starting in your Linux home, means every new tab opens straight into your development environment.
Watch out
Typing Linux commands into a PowerShell tab by mistake; check the tab title or prompt first.
Linux and Windows file systems in WSL
Also called /mnt/c, \\wsl$
- What
- Windows drives appear in WSL under
/mnt/c, and Linux files appear in File Explorer under\\wsl$. Microsoft recommends storing files on the same side as the tools that use them. - Why
- Projects you run with Linux tools belong in your Linux home, such as
~/code. Working across the boundary is much slower and file watching is unreliable. - Example
- Clone repositories into
~/code/app, open it in VS Code withcode .and in File Explorer withexplorer.exe ..
Watch out
Cloning into /mnt/c/Users/you/... and then waiting minutes for every npm install.
Terminal, shell and prompt
Also called Bash, command line, CLI, shell, prompt
- What
- The terminal is the window. The shell, such as Bash or zsh, reads your commands, expands patterns and runs programs. The prompt is the text the shell prints while waiting, often showing user, host and folder.
- Why
- Knowing which is which tells you where a problem lives: a display issue is the terminal, a "command not found" is the shell and PATH.
- Example
- In
ls -la ~/code,lsis the program,-laare options and~/codeis an argument.
Watch out
Copying the $ prompt sign from a tutorial along with the command.
System package manager
Also called package manager, apt, dnf, pacman, brew
- What
- The tool that installs, updates and removes software from trusted repositories: apt on Ubuntu and Debian, dnf on Fedora, pacman on Arch and Homebrew on macOS.
- Why
- Installing through it keeps every tool updatable and removable, and avoids random installers from download pages.
sudo apt update && sudo apt upgrade
sudo apt install git curl jq tree
apt search ripgrep
sudo apt remove treeWatch out
Installing without updating the package list first and getting "unable to locate package".
man, --help and tldr
Also called manual page, man page
- What
man cmdopens the full manual (search with/, quit withq),cmd --helpprints a summary, andtldr cmdshows short practical examples.- Why
- Looking things up in the terminal is faster than searching the web and is always right for the version you have installed.
Watch out
Running a pasted command you have not looked up, especially one with sudo, rm or a pipe into a shell.
Git configuration
Also called git config, .gitconfig
- What
- Settings stored in
~/.gitconfigfor all repositories, or.git/configfor one. Name and email are required before committing. - Why
- The email links your commits to your GitHub profile, and sensible defaults save typing and surprises.
git config --global user.name "Sara Khan"
git config --global user.email "sara@example.com"
git config --global init.defaultBranch main
git config --global core.editor "code --wait"
git config --global pull.rebase false
git config --list --show-originWatch out
On Windows, configuring Git only on the Windows side while you commit from WSL, which has its own config.
VS Code and the code command
Also called VS Code, Visual Studio Code, code command, code ., Remote - WSL, Remote - SSH
- What
- Visual Studio Code is a free editor. The
codecommand opens files and folders from the terminal; the WSL and Remote SSH extensions run VS Code's server where the files live. - Why
- Opening projects from the terminal keeps you in the right folder, and remote extensions let you edit WSL or server files as if they were local.
code . # from Ubuntu, with the WSL extension
code notes.md
code --wait msg.txtWatch out
On Windows, opening a WSL project through a \\wsl$ path in plain VS Code instead of the WSL extension.