Skip to content

Cheatsheets

One-page references for the commands and syntax you use every day.

Git

Everyday version control.

CommandWhat it does
git clone <url>Copy a remote repository to your machine
git statusSee changed, staged and untracked files
git add <file>Stage a file (use `.` for everything)
git commit -m "message"Record the staged changes
git log --oneline --graphCompact history with branches
git diffShow unstaged changes
git switch -c <branch>Create and move to a new branch
git merge <branch>Merge a branch into the current one
git pullFetch and integrate remote changes
git push -u origin <branch>Publish a branch and set its upstream
git restore <file>Discard unstaged changes to a file
git stashShelve uncommitted work temporarily (`git stash pop` to bring it back)

Linux shell

Navigating and working with files.

CommandWhat it does
pwdPrint the current directory
ls -laList files, including hidden ones, with details
cd <dir>Change directory (`cd ..` goes up, `cd` goes home)
mkdir -p a/bCreate a directory and any missing parents
cp -r <src> <dst>Copy files or directories
mv <src> <dst>Move or rename
rm -r <dir>Delete a directory and its contents (no undo)
cat <file>Print a file
grep -rn "text" .Search for text in files, with line numbers
chmod +x <file>Make a file executable
sudo apt install <pkg>Install a package on Ubuntu/Debian
ssh user@hostLog in to a remote machine

SQL (PostgreSQL)

Querying a database.

CommandWhat it does
SELECT col1, col2 FROM t;Pick columns from a table
WHERE price > 10 AND activeFilter rows
ORDER BY created_at DESCSort results
LIMIT 10 OFFSET 20Page through results
SELECT DISTINCT col FROM t;Remove duplicate values
GROUP BY colAggregate per group (with COUNT, SUM, AVG, MIN, MAX)
HAVING COUNT(*) > 5Filter groups after aggregation
JOIN b ON a.id = b.a_idCombine tables (LEFT JOIN keeps unmatched rows of a)
INSERT INTO t (a, b) VALUES (1, 2);Add a row
UPDATE t SET a = 1 WHERE id = 5;Change rows (always use WHERE)
DELETE FROM t WHERE id = 5;Remove rows (always use WHERE)
\dt · \d table · \qpsql: list tables, describe a table, quit

Python · pandas

Working with tabular data.

CommandWhat it does
df = pd.read_csv("file.csv")Load a CSV file
df.head() · df.info()Peek at rows and column types
df.describe()Summary statistics for numeric columns
df["col"] · df[["a", "b"]]Select one column or several
df[df["age"] > 18]Filter rows by a condition
df.loc[row, col] · df.iloc[i, j]Select by label or by position
df.isna().sum()Count missing values per column
df.dropna() · df.fillna(0)Drop or fill missing values
df.groupby("k")["v"].mean()Aggregate per group
df.sort_values("col", ascending=False)Sort rows
pd.merge(a, b, on="id", how="left")Join two DataFrames
df.to_csv("out.csv", index=False)Save to CSV

LaTeX

Papers and theses.

CommandWhat it does
\section{Title} · \subsection{Title}Headings
\textbf{bold} · \emph{italic}Emphasis
$x^2 + y_i$Inline math
\[ \sum_{i=1}^{n} x_i \]Displayed math
\begin{itemize} \item … \end{itemize}Bulleted list (`enumerate` for numbered)
\includegraphics[width=0.8\linewidth]{fig.png}Insert an image (needs `graphicx`)
\label{fig:a} · \ref{fig:a}Name something and refer to it
\cite{key}Cite an entry from your .bib file