Tool cheatsheet
Bash and Linux 5 Cheatsheet
Everyday shell and Linux commands for files, searching text, permissions, processes and servers.
Files and directories
- List files with details — Long listing including hidden files, with sizes you can read.
- Create nested directories — Create a folder and any missing parents.
- Copy a directory — Copy a folder and everything in it.
- Move or rename a file — Move a file, or rename it by giving a new name in the same folder.
- Delete a directory — Remove a folder and everything inside it, without prompting.
- Create a symbolic link — Make a link to a file or folder.
- Page through a file — Scroll a long file. Press q to quit.
- Follow a log file — Print new lines as they are added to a file.
- Show the first lines — Print the first 20 lines of a file.
Searching and text
- Search file contents — Search a folder recursively and show file names and line numbers.
- Find files by name — Find files whose name matches a pattern.
- Find files changed recently — Find files modified in the last day.
- Count lines — Count the lines in a file.
- Count duplicate lines — Sort lines and count how often each appears, most common first.
- Replace text in a file — Replace every occurrence of a word in place.
- Print one column — Print the second whitespace-separated column of each line.
- Run a command on a list of files — Pass matching file names to another command.
Permissions
- Make a file executable — Allow a script to be run directly.
- Set permissions with numbers — Owner read/write, everyone else read-only.
- Change the owner — Change the owner and group of a folder and everything in it.
Archives and transfer
- Create a compressed archive — Pack a folder into a .tar.gz file.
- Extract an archive — Unpack a .tar.gz file into the current folder.
- List an archive's contents — See what is inside without extracting.
- Connect to a server — Open a shell on a remote machine.
- Create an SSH key — Generate a modern Ed25519 key pair. The public key is the .pub file.
- Copy a file to a server — Copy a local file to a remote folder over SSH.
- Sync a folder to a server — Copy only what changed, preserving permissions, with progress.
Processes and system
- List processes — Show every running process with its owner and resource use.
- Find a process by name — Search the process list for a name.
- Stop a process — Ask a process to terminate gracefully using its PID.
- Force-kill a process — End a process immediately when it ignores a normal kill.
- Find what is using a port — List the process listening on a port.
- Check free disk space — Show space on each mounted filesystem in readable units.
- Find what is using space — Show the size of each item in the current folder, largest last.
- Check memory — Show used and free memory.
- Check a service — Show whether a systemd service is running.
- Follow a service's logs — Stream the journal for a systemd unit.
- Set an environment variable — Make a variable available to programs started from this shell.
Related cheatsheets
- Ansible 2 cheatsheet — Run ad-hoc commands and playbooks, manage inventories, roles, collections and secrets with Ansible.
- Argo CD 3 cheatsheet — Install Argo CD, define Applications declaratively, and manage sync, diffs, history and rollbacks with the argocd CLI.
- AWS CLI 2 cheatsheet — Configure credentials and manage S3, EC2, Lambda, logs, containers and secrets with the AWS CLI v2.
- Azure CLI 2 cheatsheet — Sign in and manage resource groups, VMs, web apps, storage, Kubernetes, registries and secrets with the az command.
- Claude API cheatsheet — Call Claude from Python, TypeScript or curl: messages, streaming, thinking, tools, structured output, caching, batches and error handling.
- Claude Code cheatsheet — Run Claude Code in the terminal: starting sessions, slash commands, permissions, CLAUDE.md, hooks, MCP servers and headless use.