A general-purpose baseline for now — the plan is to trim this down to the commands and flags I actually use day to day, and drop the rest.
Navigation
| Command | Description |
|---|
pwd | Print the current working directory. |
cd <dir> | Change directory. |
cd .. | Move up one directory. |
cd - | Switch back to the previous directory. |
cd ~ | Go to the home directory ($HOME). |
ls | List directory contents. |
ls -la | List all entries (including hidden), long format. |
ls -lh | Long format with human-readable file sizes. |
Files & directories
cp
Copy files or directories.
| Flag | Description |
|---|
-r | Copy directories recursively. |
-v | Verbose — print each file as it’s copied. |
-i | Prompt before overwriting an existing file. |
mv
Move or rename a file or directory.
| Flag | Description |
|---|
-i | Prompt before overwriting a destination. |
-v | Verbose — print each move. |
rm
Remove files or directories.
| Flag | Description |
|---|
-r | Remove directories and their contents recursively. |
-f | Force — ignore missing files, never prompt. |
-i | Prompt before every removal. |
mkdir / rmdir
| Command | Description |
|---|
mkdir <dir> | Create a directory. |
mkdir -p <a/b/c> | Create nested directories, creating parents as needed. |
rmdir <dir> | Remove an empty directory. |
touch
Create an empty file, or update its modified timestamp if it already exists.
Reading & searching text
| Command | Description |
|---|
cat <file> | Print a file’s contents. |
cat -n <file> | Print with line numbers. |
less <file> | Page through a file’s contents. |
head <file> | Show the first 10 lines. |
head -n <count> <file> | Show the first <count> lines. |
tail <file> | Show the last 10 lines. |
tail -f <file> | Follow a file as it grows (e.g. a log). |
wc -l <file> | Count lines in a file. |
grep
Search text using patterns.
| Flag | Description |
|---|
-i | Case-insensitive search. |
-r | Search recursively through a directory. |
-n | Show line numbers with matches. |
-v | Invert match — show non-matching lines. |
-E | Use extended regular expressions. |
find
Locate files and directories.
| Example | Description |
|---|
find . -name "*.md" | Find files by name pattern under the current directory. |
find . -type d | Find directories only. |
find . -mtime -1 | Find files modified in the last day. |
Permissions & ownership
| Command | Description |
|---|
chmod +x <file> | Make a file executable. |
chmod 644 <file> | Set explicit permission bits (owner rw, group/other r). |
ls -l | Show permission bits alongside file listings. |
Process & environment
| Command | Description |
|---|
ps | List running processes for the current shell session. |
kill <pid> | Terminate a process by PID. |
which <cmd> | Show the path to the executable that would run for <cmd>. |
alias ll='ls -la' | Define a shortcut command for the current session. |
export VAR=value | Set an environment variable for the current shell and its children. |
echo $VAR | Print the value of an environment variable. |
history | Show recently run commands. |
clear | Clear the terminal screen. |
Windows-specific notes
- Git Bash provides a MinGW/MSYS POSIX layer over Windows — most core utilities above (
ls, grep, find, etc.) are real GNU coreutils, not emulations.
- Windows paths and POSIX paths are both understood:
cd /c/Users/<name> is equivalent to C:\Users\<name>.
- Use
winpty <command> to fix broken interactive input/output for some native Windows console programs run from Git Bash.
- Line endings: configure
git config --global core.autocrlf true so Git converts LF to CRLF on checkout and back on commit for cross-platform repos.
- There’s no native
sudo; commands requiring elevation are run from an elevated Windows terminal instead.