Linux, terminal and Git: macOS

Sefism.

A to Z

Glossary

Every concept in this sheet, plus the smaller terms it uses. Select a concept to open its card.

#
.gitignore
A file listing patterns Git should not track, such as dependencies, build output, logs and secrets.
A
Absolute and relative paths
An absolute path starts at the root /; a relative path starts from the current folder.
awk
Processes text line by line, splitting each line into fields $1, $2 and so on, with -F to choose the separator.
B
Branches
A branch is a movable name pointing at a commit.
C
cat, less, head and tail
cat prints a file, less lets you scroll and search it, head and tail show the start and end, and tail -f follows a growing file.
chmod
Changes permissions, either symbolically (u+x, go-w) or numerically, where read is 4, write 2 and execute 1 for each of owner, group and others.
Code review
Reading a teammate's change to check correctness, tests, clarity and fit, and leaving comments, suggestions or approval.
Commit messages
A short imperative summary of about 50 characters, a blank line, then a body explaining why when needed.
Commits and snapshots
A commit is a snapshot of the whole project plus a message, author and a pointer to its parent commit, identified by a hash.
Conditionals and tests
if [[ ... ]]; then ... fi runs code based on a test: -f file exists, -d folder exists, -z empty string, == string match, -gt number comparison.
cron
Runs commands on a schedule defined by five fields: minute, hour, day of month, month, day of week.
curl
Sends HTTP and other requests from the terminal and prints the response.
D
Disk and system checks
df -h shows free space per file system, du -sh shows how big folders are, free -h shows memory on Linux and uname -a shows the kernel.
DNS and reachability checks
dig or nslookup show what a name resolves to; ping checks whether a host answers; traceroute shows the path.
Dotfiles repository
Your configuration files kept in a Git repository, with an install script that links them into your home with ln -s.
E
Environment debugging checklist
A fixed order of checks: read the full error, ask what changed, then check which binary runs, PATH, permissions, environment variables, disk, processes, ports and logs.
Environment variables
Named values inherited by every program the shell starts, such as HOME, USER, EDITOR and PATH.
Exit codes
Every command returns a number: 0 means success, anything else failure.
F
fetch, pull and push
fetch downloads new commits without changing your files, pull fetches and then merges or rebases, and push uploads your commits.
File commands
mkdir -p creates folders (and parents), touch creates an empty file, cp -r copies, mv moves or renames, rm deletes and rm -r deletes folders.
find
Walks a folder tree and matches files by name, type, size or modification time, optionally running an action on each.
First steps on a new server
Update packages, create a sudo user with key login, disable root and password login in /etc/ssh/sshd_config, and enable a firewall allowing only what you need.
Forks and syncing
A fork is your own copy of someone else's repository on GitHub.
Functions and script structure
Named blocks of commands, called like programs, with local variables.
G
Git configuration
Settings stored in ~/.gitconfig for all repositories, or .git/config for one.
git log and git diff
git log shows history, git diff shows changes, git show shows one commit and git blame shows who last changed each line.
git reflog
A local log of every position HEAD has been at, including commits no branch points to any more.
git stash
Saves uncommitted changes on a stack and cleans the working tree, so you can switch tasks and restore them later.
GitHub CLI
The official command-line tool for GitHub: repositories, pull requests, issues, releases and Actions runs from the terminal.
GitHub flow
A lightweight workflow: main is always deployable; each change gets a branch, commits, a pull request, review and checks, then a merge and branch deletion.
Globbing and brace expansion
The shell expands * (any characters), ? (one character) and [abc] (one of a set) into matching file names before the command runs.
grep
Prints lines that match a pattern, in files or in piped input.
H
Homebrew
The package manager for macOS (it also runs on Linux).
I
Installing developer tools
System tools come from the system package manager; project libraries come from language managers such as pip and npm, installed per project.
J
Jobs: foreground and background
cmd & starts a job in the background, Ctrl+Z pauses the foreground job, bg resumes it in the background, fg brings it back and jobs lists them.
jq
A command-line tool for reading, filtering and reshaping JSON.
L
Loops
for loops over a list or glob; while read -r line reads input line by line.
M
man, --help and tldr
man cmd opens the full manual (search with /, quit with q), cmd --help prints a summary, and tldr cmd shows short practical examples.
Merge
Combines another branch into the current one, with a merge commit when histories diverged or a fast-forward when they did not.
Merge conflicts
When two branches change the same lines, Git stops and marks the file with <<<<<<<, ======= and >>>>>>> sections for you to resolve.
N
nano and Vim
Terminal editors. nano shows its shortcuts: Ctrl+O saves, Ctrl+X exits.
O
Opening files and the clipboard
Commands that hand a file to your desktop or move text to and from the clipboard.
Ownership and chown
Every file belongs to a user and a group.
P
PATH
A colon-separated list of folders the shell searches, in order, for commands.
Permission bits
Each file has read, write and execute permissions for its owner, its group and everyone else, shown by ls -l as, for example, rwxr-xr--.
Pipes
A pipe | sends the standard output of one command into the standard input of the next.
Ports and listening processes
A service listens on a port; ss -tlnp (Linux) or lsof -i :PORT shows which process owns it.
Processes
A running program, with a process ID, an owner and a parent.
Pull request
A request to merge a branch, with a description, discussion, review and automated checks.
Q
Quoting
Single quotes keep text exactly as written.
R
Rebase
Replays your commits on top of another branch, creating new commits with new hashes.
Redirection and the three streams
Programs read standard input and write standard output and standard error.
Regular expressions
A pattern language: . any character, * zero or more, + one or more, ? optional, ^ and $ start and end of line, [0-9] a set, ( ) a group.
Remotes
Named links to other copies of the repository.
root, sudo, users and groups
root can do anything.
S
scp and rsync
scp copies files over SSH; rsync synchronises folders, sending only changes.
Secrets in Git
Passwords, tokens and keys committed to a repository stay in its history even after you delete the file.
sed
Edits text as it streams through, most often with substitution s/old/new/g.
set -euo pipefail
-e stops on a failing command, -u treats unset variables as errors, and pipefail makes a pipeline fail if any part fails.
Shebang and executable scripts
The first line #!/usr/bin/env bash chooses the interpreter.
Shell startup files and aliases
Files the shell runs when it starts: ~/.bashrc for interactive Bash, ~/.zshrc for zsh, and login files such as ~/.profile or ~/.zprofile.
ShellCheck
A static analyser for shell scripts that warns about quoting bugs, ignored errors, wrong test syntax and more, each with a numbered explanation page.
Signals and kill
Messages sent to a process.
sort, uniq, cut, tr and wc
Small tools that reorder, count, slice and clean lines of text.
SSH config file
A file of named Host blocks with the address, user, port and key for each machine.
SSH keys
A key pair: a private key that stays on your machine and a public key (.pub) you give to GitHub or a server.
SSH login
ssh user@host opens a secure shell on another machine.
System package manager
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.
systemctl and journalctl
systemd starts and supervises services.
T
Terminal, iTerm2 and zsh on macOS
macOS ships Terminal; iTerm2 is a popular free alternative.
Terminal, shell and prompt
The terminal is the window.
tmux
Keeps terminal sessions running on a machine after you disconnect, with windows and split panes.
U
Undoing changes
restore discards or unstages changes, commit --amend fixes the last local commit, revert adds a commit that undoes another, and reset moves a branch back.
V
Variables and arguments
$1, $2 are positional arguments, "$@" is all of them, $# is the count, ${var:-default} gives a fallback and $(cmd) captures output.
Version managers
Tools that install several versions of a language in your home folder and switch between them by changing PATH, such as nvm for Node and pyenv for Python.
VS Code and the code command
Visual Studio Code is a free editor.
W
Working tree, staging area and repository
Changes move from the working tree (your files) to the staging area with git add, then into history with git commit.
X
Xcode Command Line Tools
Apple's compilers, git, make and related developer tools, installed without the full Xcode app by running xcode-select --install.
09 · Glossary, A to Z9 / 9