Recipes
Setup Useful Git Aliases
Recommended aliases from git documentation.
# Shortening Aliasesgit config --global alias.co checkoutgit config --global alias.br branchgit config --global alias.cm commitgit config --global alias.st status# Simplify Common Actionsgit config --global alias.unstage 'reset HEAD --'git config --global alias.last 'log -1 HEAD'
Git Feature Branch Workflow
Create a feature branch, make changes, and merge back to main.
# Create and switch to feature branchgit checkout -b feature/my-feature# Make your changes, then stage and commitgit add .git commit -m "Add new feature"# Push feature branch to remotegit push -u origin feature/my-feature# After PR is merged, cleanupgit checkout maingit pullgit branch -d feature/my-feature
Undo Last Git Commit
Undo the last commit while keeping changes staged.
# Undo last commit, keep changes stagedgit reset --soft HEAD~1# Or undo and unstage changesgit reset HEAD~1# Or completely discard changes (DESTRUCTIVE)git reset --hard HEAD~1
Git Stash Workflow
Save work in progress, switch branches, and restore.
# Save current changes to stashgit stash push -m "WIP: work in progress"# List all stashesgit stash list# Apply most recent stash (keeps stash)git stash apply# Apply and remove most recent stashgit stash pop# Apply a specific stashgit stash apply stash@{0}
Interactive Git Rebase
Squash, reorder, or edit recent commits.
# Rebase last N commits interactivelygit rebase -i HEAD~3# In the editor, change 'pick' to:# - 'squash' or 's' to combine with previous# - 'reword' or 'r' to edit message# - 'drop' or 'd' to remove commit# - 'edit' or 'e' to stop and amend# If you mess up, abort:git rebase --abort
Docker Compose Dev Environment
Start, stop, and manage a Docker Compose environment.
# Start all services in backgrounddocker compose up -d# View logs (follow mode)docker compose logs -f app# Rebuild and restart a specific servicedocker compose up -d --build app# Stop all servicesdocker compose down# Stop and remove volumes (DESTRUCTIVE)docker compose down -v
Docker Cleanup
Remove unused Docker resources to free disk space.
# Remove stopped containersdocker container prune -f# Remove unused imagesdocker image prune -f# Remove unused volumes (CAREFUL - data loss)docker volume prune -f# Nuclear option: remove everything unuseddocker system prune -a -f --volumes# Check disk usagedocker system df
Docker Build and Push
Build a Docker image and push to a registry.
# Build with tagdocker build -t myapp:latest .# Tag for registrydocker tag myapp:latest ghcr.io/username/myapp:latest# Push to registrydocker push ghcr.io/username/myapp:latest
SSH Key Setup
Generate SSH key and add to ssh-agent.
# Generate new SSH keyssh-keygen -t ed25519 -C "[email protected]"# Start ssh-agenteval "$(ssh-agent -s)"# Add key to agentssh-add ~/.ssh/id_ed25519# Copy public key to clipboard (macOS)cat ~/.ssh/id_ed25519.pub | pbcopy# Test connection (for GitHub)ssh -T [email protected]
Find and Kill Process by Port
Find which process is using a port and kill it.
# Find process using port (macOS/Linux)lsof -i :3000# Kill process by PIDkill -9 12345# One-liner to kill process on port (macOS)lsof -ti :3000 | xargs kill -9# Alternative using fuser (Linux)fuser -k 3000/tcp
Disk Space Analysis
Find what's using disk space.
# Show disk usage summarydf -h# Find largest directories in current folderdu -sh * | sort -hr | head -20# Find largest files (over 100MB)find . -type f -size +100M -exec ls -lh {} \;# Interactive disk usage (if ncdu installed)ncdu .
Create Node.js Project
Initialize a new Node.js project with TypeScript.
# Create directory and initmkdir my-project && cd my-projectnpm init -y# Install TypeScript and typesnpm install -D typescript @types/node ts-node# Create tsconfignpx tsc --init# Create source directorymkdir src && touch src/index.ts# Add scripts to package.jsonnpm pkg set scripts.build="tsc"npm pkg set scripts.dev="ts-node src/index.ts"
Quick HTTP Server
Serve current directory over HTTP for testing.
# Python 3python3 -m http.server 8000# Node.js (npx)npx serve -p 8000# PHPphp -S localhost:8000
Generate Random Password
Generate a secure random password.
# Using opensslopenssl rand -base64 32# Using /dev/urandom (alphanumeric)cat /dev/urandom | tr -dc 'a-zA-Z0-9' | fold -w 32 | head -n 1# Using Pythonpython3 -c "import secrets; print(secrets.token_urlsafe(32))"
Tail Logs with Highlight
Monitor log files with pattern highlighting.
# Tail with grep highlighttail -f /var/log/app.log | grep --color=always -E 'ERROR|$'# Multiple patternstail -f /var/log/app.log | grep --color=always -E 'ERROR|WARN|$'# Using less for scrollbackless +F /var/log/app.log
Sync Files with Rsync
Efficiently sync files between locations.
# Sync local to remotersync -avz --progress ./src/ [email protected]:/backup/src/# Sync with delete (mirror exactly)rsync -avz --delete ./src/ /backup/src/# Dry run (see what would happen)rsync -avzn ./src/ /backup/src/# Exclude patternsrsync -avz --exclude='node_modules' --exclude='.git' ./src/ /backup/src/
All Commands
Create aliases - words that are replaced by a command string. Aliases expire with the current shell session unless defined in the shell's configuration file, e.g. `~/.bashrc` for Bash or `~/.zshrc` for Zsh. See also: `unalias`.
6 examples
Manage groups of computers remotely over SSH. (use the `/etc/ansible/hosts` file to add new groups/hosts). Some subcommands such as `galaxy` have their own usage documentation.
7 examples
Package manager for Debian-based distributions. Intended as a user-friendly alternative to `apt-get` for interactive use. For equivalent commands in other package managers, see <https://wiki.archlinux.org/title/Pacman/Rosetta>.
8 examples
Debian and Ubuntu package management utility. Search for packages using `apt-cache`. It is recommended to use `apt` when used interactively in Ubuntu versions 16.04 and later.
8 examples
A versatile programming language for working on files. Note: Different implementations of AWK often make this a symlink of their binary. See also: `gawk`.
8 examples
The official CLI tool for Amazon Web Services. Some subcommands such as `s3` have their own usage documentation.
8 examples
The official CLI tool for Microsoft Azure. Some subcommands such as `login` have their own usage documentation.
8 examples
Encode or decode file or `stdin` to/from base64, to `stdout`.
5 examples
JavaScript runtime and toolkit. Includes a bundler, a test runner, and a package manager.
8 examples
Display a calendar with the current day highlighted. See also: `gcal`.
3 examples
Manage Rust projects and their module dependencies (crates). Some subcommands such as `build` have their own usage documentation.
8 examples
Print and concatenate files.
5 examples
Change the current working directory.
6 examples
Change the access permissions of a file or directory.
8 examples
Change user and group ownership of files and directories. See also: `chgrp`.
7 examples
Cross-platform build automation system, that generates recipes for native build systems.
8 examples
Cross platform and extensible code editor.
8 examples
This command is an alias of `magick convert`. Note: This alias is deprecated since ImageMagick 7. It has been replaced by `magick`. Use `magick convert` if you need to use the old tool in versions 7+.
1 example
Copy files and directories.
8 examples
A system scheduler for running jobs or tasks unattended. The command to submit, edit, or delete entries to `cron` is called `crontab`.
1 example
Schedule cron jobs to run on a time interval for the current user.
8 examples
Transfers data from or to a server. Supports most protocols, including HTTP, HTTPS, FTP, SCP, etc. See also: `wcurl`, `wget`.
8 examples
Set or display the system date.
8 examples
Display an overview of the filesystem disk space usage.
4 examples
Compare files and directories. See also: `delta`, `difft`.
8 examples
Manage Docker containers and images. Some subcommands such as `container` and `image` have their own usage documentation.
8 examples
Build an image from a Dockerfile.
7 examples
Run and manage multi container Docker applications.
8 examples
This command is an alias of `docker container exec`.
1 example
This command is an alias of `docker container logs`.
1 example
This command is an alias of `docker container ls`.
1 example
This command is an alias of `docker image pull`.
1 example
This command is an alias of `docker container rm`.
1 example
This command is an alias of `docker container run`.
1 example
Disk usage: estimate and summarize file and directory space usage.
7 examples
Print given arguments. See also: `printf`.
7 examples
Show the environment or run a program in a modified environment.
7 examples
Export shell variables to child processes.
2 examples
Video conversion tool. See also: `gst-launch-1.0`.
8 examples
Find files or directories under a directory tree, recursively. See also: `fd`.
8 examples
Display amount of free and used memory in the system.
4 examples
Compile C++ source files. Part of GCC (GNU Compiler Collection).
8 examples
Preprocess and compile C and C++ source files, then assemble and link them together. Part of GCC (GNU Compiler Collection).
8 examples
The official CLI tool for Google Cloud Platform. Some subcommands such as `app` and `init` have their own usage documentation.
8 examples
The GNU Debugger.
6 examples
Work seamlessly with GitHub. Some subcommands such as `config` have their own usage documentation.
8 examples
Distributed version control system. Some subcommands such as `commit`, `add`, `branch`, `switch`, `push`, etc. have their own usage documentation.
8 examples
Adds changed files to the index.
8 examples
Main Git command for working with branches.
8 examples
Checkout a branch or paths to the working tree.
8 examples
Clone an existing repository.
8 examples
Commit files to the repository.
7 examples
Show changes to tracked files.
8 examples
Download objects and refs from a remote repository.
7 examples
Initialize a new local Git repository.
4 examples
Show a history of commits.
8 examples
Merge branches.
5 examples
Fetch branch from a remote repository and merge it to local repository.
3 examples
Push commits to a remote repository.
8 examples
Reapply commits from one branch on top of another branch. Commonly used to "move" an entire branch to another base, creating copies of the commits in the new location.
8 examples
Manage set of tracked repositories ("remotes").
7 examples
Undo commits or unstage changes by resetting the current Git HEAD to the specified state. If a path is passed, it works as "unstage"; if a commit hash or branch is passed, it works as "uncommit".
7 examples
Create new commits which reverse the effect of earlier ones.
6 examples
Stash local Git changes in a temporary area.
8 examples
Show the changes to files in a Git repository. List changed, added, and deleted files compared to the currently checked-out commit.
7 examples
Switch between Git branches. Requires Git version 2.23+. See also: `git checkout`.
7 examples
Create, list, delete, or verify tags. A tag is a static reference to a commit.
8 examples
Manage Go source code. Some subcommands such as `build` have their own usage documentation.
7 examples
Find patterns in files using `regex`es. See also: `regex`.
8 examples
This command is an alias of `gzip --decompress`.
1 example
Compress/uncompress files with `gzip` compression (LZ77).
8 examples
Output the first part of files.
1 example
Manage command-line history.
8 examples
Show or set the system's host name.
4 examples
Display dynamic real-time information about running processes. An enhanced version of `top`. See also: `top`, `atop`, `glances`, `btop`, `btm`.
8 examples
Network Interface Configurator.
5 examples
Show/manipulate routing, devices, policy routing and tunnels. Some subcommands such as `address` have their own usage documentation.
8 examples
Java application launcher.
6 examples
Java application compiler.
4 examples
A JSON processor that uses a domain-specific language (DSL).
8 examples
Send a signal to a process, usually related to stopping the process. All signals except for SIGKILL and SIGSTOP can be intercepted by the process to perform a clean exit.
7 examples
Send kill signal to all instances of a process by name (must be exact name). All signals except SIGKILL and SIGSTOP can be intercepted by the process, allowing a clean exit.
5 examples
Run commands against Kubernetes clusters. Some subcommands such as `run` have their own usage documentation.
8 examples
Open a file for interactive reading, allowing scrolling and search.
8 examples
Create links to files and directories.
4 examples
List directory contents.
8 examples
Task runner for targets described in Makefile. Mostly used to control the compilation of an executable from source code.
8 examples
Format and display manual pages. See also: `whatis`, `apropos`.
8 examples
Calculate MD5 cryptographic checksums.
7 examples
Create directories and set their permissions.
4 examples
A new shell for MongoDB, replacement for `mongo`. Note: All connection options can be replaced with one string: `mongodb://user@host:port/db_name?authSource=authdb_name`.
4 examples
Move or rename files and directories.
8 examples
The MySQL tool.
7 examples
Text editor. An enhanced `pico` clone. See also: `pico`, `rnano`.
8 examples
Display network-related information such as open connections, open socket ports, etc. See also: `ss`.
7 examples
Network exploration tool and security/port scanner. Some features (e.g. SYN scan) activate only when `nmap` is run with root privileges. See also: `hping3`, `masscan`, `naabu`, `rustscan`, `zmap`.
8 examples
Server-side JavaScript platform (Node.js).
6 examples
Allows for a process to live when the terminal gets killed.
4 examples
JavaScript and Node.js package manager. Manage Node.js projects and their module dependencies.
8 examples
This command is an alias of `npm exec`.
1 example
OpenSSL cryptographic toolkit. Some subcommands such as `req` have their own usage documentation.
8 examples
Send ICMP ECHO_REQUEST packets to network hosts.
7 examples
Python package manager. Some subcommands such as `install` have their own usage documentation.
8 examples
This command is an alias of `pip`.
1 example
Signal process by name. Mostly used for stopping processes.
5 examples
Fast, disk space efficient package manager for Node.js. Manage Node.js projects and their module dependencies.
8 examples
Format and print text. See also: `echo`.
6 examples
Information about running processes.
7 examples
PostgreSQL client.
5 examples
Python language interpreter.
8 examples
This command is an alias of `python`.
1 example
Open a connection to a Redis server.
7 examples
Remove files or directories. See also: `rmdir`, `trash`.
6 examples
Remove directories without files. See also: `rm`.
3 examples
Transfer files either to or from a remote host (but not between two remote hosts), by default using SSH. To specify a remote path, use `user@host:path/to/file_or_directory`.
8 examples
The Rust compiler. Rust projects usually use `cargo` instead of invoking `rustc` directly.
7 examples
Secure copy. Copy files between hosts using Secure Copy Protocol over SSH.
8 examples
Hold a session open on a remote server. Manage multiple windows with a single SSH connection. See also: `tmux`, `zellij`.
8 examples
Edit text in a scriptable manner. See also: `awk`, `ed`.
3 examples
Calculate SHA256 cryptographic checksums.
7 examples
Sort lines of text files.
8 examples
Execute commands from a file in the current shell.
2 examples
Secure Shell is a protocol used to securely log onto remote systems. It can be used for logging or executing commands on a remote server.
8 examples
Execute a single command as the superuser or another user. See also: `pkexec`, `run0`, `doas`.
8 examples
Control the systemd system and service manager. Some subcommands such as `disable`, `status`, `reboot` etc. have their own usage documentation.
8 examples
Display the last part of a file. See also: `head`.
8 examples
Archiving utility. Often combined with a compression method, such as `gzip` or `bzip2`.
8 examples
Read from `stdin` and write to `stdout` and files (or commands).
4 examples
Create and deploy infrastructure as code to cloud providers.
6 examples
Terminal multiplexer. It allows multiple sessions with windows, panes, and more. See also: `zellij`, `screen`.
8 examples
Create files and set access/modification times.
7 examples
Print details about the current machine and the operating system running on it. See also: `lsb_release`.
7 examples
Output the unique lines from a input or file. Since it does not detect repeated lines unless they are adjacent, we need to sort them first. See also: `sort`.
7 examples
Extract files/directories from Zip archives. See also: `zip`.
6 examples
Tell how long the system has been running and other information.
5 examples
Vim (Vi IMproved), a command-line text editor, provides several modes for different kinds of text manipulation. Pressing `<i>` in normal mode enters insert mode. Pressing `<Esc>` goes back to normal mode, which enables the use of Vim commands. See also: `vimdiff`, `vimtutor`, `nvim`, `gvim`.
8 examples
Count lines, words, and bytes.
6 examples
Download files from the Web. Supports HTTP, HTTPS, and FTP. See also: `wcurl`, `curl`.
8 examples
Locate a program in the user's `$PATH`. See also: `whereis`, `type`.
2 examples
This command is an alias of `id --user --name`.
1 example
Execute a command with piped arguments coming from another command, a file, etc. The input is treated as a single block of text and split into separate pieces on spaces, tabs, newlines, and end-of-file. See also: `parallel`.
8 examples
JavaScript and Node.js package manager alternative.
6 examples
A lightweight and portable YAML processor.
8 examples
Package and compress (archive) files into a Zip archive. See also: `unzip`.
7 examples