Skip to main content

Chapter 25: Appendix

Quick reference, cross-platform comparison, and resources — one page to rule them all.

Chapter Goals​

This chapter is a reference appendix for the entire book, providing:

  • Common terminal command quick reference
  • macOS / Ubuntu / Windows three-platform command comparison
  • Common errors and troubleshooting approaches
  • Recommended learning resources

25.1 Common Terminal Commands Quick Reference​

File and Directory Operations​

CommandFunctionExample
lsList filesls -la
cdChange directorycd ~/research
pwdShow current directorypwd
mkdirCreate directorymkdir -p src/utils
rmDelete filerm file.txt
rm -rDelete directoryrm -r old_dir/
cpCopycp file.txt backup/
cp -rCopy directorycp -r src/ src_backup/
mvMove/renamemv old.py new.py
touchCreate empty filetouch README.md
catView file contentscat config.yaml
lessPaginated viewingless long_output.log
headView first N lineshead -20 data.csv
tailView last N linestail -f simulation.log
wcCount lines/words/characterswc -l data.csv
findFind filesfind . -name "*.py"
treeDirectory treetree -L 2

Text Processing​

CommandFunctionExample
grepSearch textgrep "error" log.txt
grep -rRecursive searchgrep -rn "def main" src/
sedText replacementsed -i 's/old/new/g' file.txt
awkColumn processingawk '{print $1, $3}' data.txt
sortSortsort -n -k2 data.txt
uniqDeduplicatesort data.txt | uniq -c
cutExtract columnscut -d',' -f1,3 data.csv
diffCompare filesdiff file1.txt file2.txt

System and Processes​

CommandFunctionExample
top / htopView processeshtop
psList processesps aux | grep python
killTerminate processkill -9 12345
dfDisk usagedf -h
duDirectory sizedu -sh data/
freeMemory usagefree -h (Linux)
whichCommand locationwhich python3
chmodChange permissionschmod +x run.sh
chownChange ownershipchown user:group file

Network​

CommandFunctionExample
sshRemote loginssh user@server.edu
scpRemote copyscp file.txt user@server:~/
rsyncIncremental syncrsync -avh src/ dest/
wgetDownload filewget https://example.com/data.tar.gz
curlHTTP requestcurl -O https://example.com/file
pingTest connectivityping google.com

Git​

CommandFunctionExample
git initInitialize repositorygit init
git cloneClone repositorygit clone https://github.com/user/repo.git
git statusView statusgit status
git addStage filesgit add src/model.py
git commitCommitgit commit -m "Add model"
git pushPushgit push origin main
git pullPullgit pull origin main
git logView historygit log --oneline -10
git diffView differencesgit diff HEAD~1
git branchBranch operationsgit branch feature-x
git checkoutSwitch branchgit checkout feature-x
git mergeMerge branchgit merge feature-x
git stashStash changesgit stash / git stash pop

25.2 macOS / Ubuntu / Windows Comparison​

Package Managers​

OperationmacOS (Homebrew)Ubuntu (apt)Windows (winget)
Install packagebrew install Xsudo apt install Xwinget install X
Search packagebrew search Xapt search Xwinget search X
Upgrade packagebrew upgrade Xsudo apt upgrade Xwinget upgrade X
Uninstall packagebrew uninstall Xsudo apt remove Xwinget uninstall X
Update indexbrew updatesudo apt update(automatic)
List installedbrew listapt list --installedwinget list

System Operations​

OperationmacOSUbuntuWindows
Open terminalTerminal / iTerm2Ctrl+Alt+TWindows Terminal
File managerFinderNautilusExplorer
Shellzsh (default)bash (default)PowerShell / bash (WSL)
Admin privilegessudosudoRun as admin / sudo in WSL
View PATHecho $PATHecho $PATHecho $PATH (bash) / $env:PATH (PS)
Env variable config~/.zshrc~/.bashrc~/.bashrc (WSL)
OperationmacOSUbuntuWindows
Install Pythonbrew install pythonsudo apt install python3winget install Python.Python.3.12
Invoke Pythonpython3python3python or python3
Create virtual envpython3 -m venv .venvpython3 -m venv .venvpython -m venv .venv
Activate virtual envsource .venv/bin/activatesource .venv/bin/activate.venv\Scripts\activate (PS) or source .venv/bin/activate (WSL)
pip installpip install Xpip install Xpip install X
OperationmacOSUbuntuWindows (WSL)
C compilergcc (actually clang) or brew install gccsudo apt install gccsudo apt install gcc
C++ compilerg++ or clang++g++g++
Fortranbrew install gfortransudo apt install gfortransudo apt install gfortran
MakeBuilt-insudo apt install makesudo apt install make
CMakebrew install cmakesudo apt install cmakesudo apt install cmake

25.3 Common Errors and Troubleshooting​

ErrorCauseSolution
ModuleNotFoundError: No module named 'numpy'Not installed or not in current environmentpip install numpy, check virtual environment
command not found: pythonPython not installed or not in PATHInstall Python, check PATH
PermissionError: [Errno 13]No file permissionsCheck file permissions, don't use sudo pip install
SyntaxError: invalid syntaxWrong Python version or syntax errorCheck python3 --version
externally-managed-environmentUbuntu 23.04+ PEP 668 protectionUse a virtual environment
RecursionError: maximum recursion depth exceededInfinite recursionCheck recursion termination condition
ErrorCauseSolution
fatal: not a git repositoryNot in a Git repositorycd to the repo directory or git init
error: failed to push some refsRemote has updatesgit pull first, then git push
CONFLICT (content): Merge conflictMerge conflictManually edit conflicting files, git add + git commit
Permission denied (publickey)SSH key not configuredConfigure SSH key, add to GitHub
fatal: remote origin already existsRemote already existsgit remote set-url origin <new-url>
ErrorCauseSolution
gcc: command not foundCompiler not installedInstall gcc (see Section 25.2)
undefined reference to 'xxx'Symbol not found during linkingCheck library linking -lxxx, check function declaration
fatal error: xxx.h: No such fileMissing header fileInstall the corresponding -dev package
error: 'for' loop initial declarationsC standard too oldAdd -std=c99 or -std=c11
Segmentation fault (core dumped)Memory access out of boundsDebug with gdb, check array indices
ErrorCauseSolution
Connection refusedServer SSH not running or wrong portConfirm server address and port
Connection timed outNetwork unreachableCheck network, check firewall
Host key verification failedServer fingerprint changedDelete the corresponding entry in ~/.ssh/known_hosts
Permission denied (publickey)SSH key mismatchCheck key configuration in ~/.ssh/

General Troubleshooting Approach​

1. Read the error message carefully (start from the last line)
2. Copy the error message into a search engine
3. Check: Is the version correct? Is the path correct? Are permissions sufficient?
4. Simplify the problem: reproduce the error with a minimal example
5. Check documentation: official docs > Stack Overflow > blog posts
6. Ask AI: give the full error message to ChatGPT/Claude

Online Courses​

CoursePlatformContent
MIT Missing SemesterMIT OCWTerminal, Git, editors, and other tools
Software CarpentryOfficial siteShell, Git, Python for researchers
CS 61A (Berkeley)Official sitePython programming fundamentals
Computational Physics (various universities)Coursera/edXNumerical methods and programming

Useful Websites​

WebsitePurpose
Stack OverflowProgramming Q&A
GitHubCode hosting and open-source projects
arXivPhysics preprints
OverleafOnline LaTeX editing
NumPy DocumentationNumPy reference
Matplotlib GalleryPlotting examples
Learn X in Y MinutesQuick language learning
explainshell.comExplain shell commands
regex101.comRegular expression testing

FAQ​

Q: Should I memorize all these commands? A: No need to memorize everything. The 20-30 commonly used commands will be remembered naturally through use. For the rest, just look them up. What matters is knowing what's possible — you can always look up the exact syntax.

Q: Is sed on macOS different from Linux? A: Yes, macOS uses BSD sed while Linux uses GNU sed. The main difference is the -i parameter: macOS requires sed -i '' 's/...', Linux uses sed -i 's/...' directly. Install GNU sed: brew install gnu-sed.

Q: Should I use Bash or Zsh? A: macOS defaults to Zsh, Linux defaults to Bash. Their syntax is 95% identical. It's recommended to use your system's default — no need to switch intentionally.


Summary​

This chapter provides quick reference for daily use:

  • Command quick reference: File operations, text processing, system management, network, Git
  • Three-platform comparison: Package management, Python, and compilation tool differences across platforms
  • Error quick reference: Common errors and solutions for Python, Git, compilation, and SSH
  • Learning resources: Recommended courses and websites

Consider bookmarking this chapter for quick reference when you encounter problems.