TLDR reference
Bash commands
A searchable cheatsheet of everyday bash and Linux tasks paired with the exact command. Type what you want to do, or filter by intent. Everything runs in your browser.
40 shown
-
List files in detail
Files & directoriesls -lah
Long listing with human-readable sizes and hidden files.
-
Make a directory (and parents)
Files & directoriesmkdir -p path/to/dir
-p creates every missing parent and never errors if it already exists.
-
Copy a directory recursively
Files & directoriescp -r src/ dest/
-r copies the folder and everything inside it.
-
Move or rename
Files & directoriesmv old.txt new.txt
The same command renames a file and moves it between directories.
-
Delete recursively
Files & directoriesrm -rf dir/
Removes a folder and its contents without prompting. Powerful and unforgiving - check the path.
-
Find files by name
Files & directoriesfind . -name '*.log'
Searches the current tree for files matching the pattern.
-
Create an empty file or bump its time
Files & directoriestouch file.txt
Creates the file if missing, otherwise updates its modified time.
-
Show the current directory
Files & directoriespwd
Prints the full path of the working directory.
-
Print a file
Viewing & searching textcat file.txt
Dumps the whole file to the terminal.
-
Page through a file
Viewing & searching textless file.txt
Scroll with arrows, search with /, quit with q. Does not load it all at once.
-
Show the first or last lines
Viewing & searching texthead -n 20 file tail -n 20 file
head shows the top, tail the bottom. Default is 10 lines.
-
Follow a growing log
Viewing & searching texttail -f app.log
-f streams new lines as they are written, ideal for live logs.
-
Search inside files
Viewing & searching textgrep -rn 'TODO' src/
-r recurses, -n prints line numbers. The everyday code search.
-
Count lines, words, bytes
Viewing & searching textwc -l file.txt
-l counts lines; drop it for words and bytes too.
-
Replace text in a stream
Viewing & searching textsed 's/old/new/g' file
Substitutes every match; add -i to edit the file in place.
-
Pick a column
Viewing & searching textawk '{print $2}' filePrints the second whitespace-separated field of each line.
-
See running processes
Processesps aux
A snapshot of every process with its user, CPU, and memory.
-
Watch processes live
Processestop
An updating view of CPU and memory use. htop is a friendlier alternative.
-
Kill a process
Processeskill -9 <pid>
Sends SIGKILL to force-stop a process by its id. Try plain kill first.
-
Kill by name
Processespkill firefox
Stops every process whose name matches.
-
Run in the background
Processeslong-task &
The trailing & detaches the command so the shell stays free.
-
Find what uses a port
Processeslsof -i :8080
Lists the process listening on a port - handy for "address already in use".
-
Make a script executable
Permissions & ownershipchmod +x script.sh
Adds the execute bit so you can run ./script.sh.
-
Set permissions by number
Permissions & ownershipchmod 644 file
644 is read/write for the owner, read-only for everyone else.
-
Change owner
Permissions & ownershipsudo chown user:group file
Reassigns the owning user and group. -R applies it recursively.
-
Run a command as root
Permissions & ownershipsudo command
Runs the command with administrator privileges.
-
Fetch a URL
Networkingcurl -L https://example.com
-L follows redirects. Add -O to save it to a file.
-
Download a file
Networkingwget https://example.com/file
Saves the file to the current directory.
-
Test connectivity
Networkingping example.com
Sends echo requests to check if a host is reachable.
-
Show listening sockets
Networkingss -tulpn
Lists TCP/UDP listeners with the owning process. The modern netstat.
-
Look up DNS
Networkingdig example.com
Queries DNS records. nslookup is a simpler alternative.
-
Create a tar.gz archive
Archives & compressiontar -czf out.tar.gz dir/
c create, z gzip, f file. The classic bundle-and-compress.
-
Extract a tar.gz archive
Archives & compressiontar -xzf out.tar.gz
x extracts; add -C dir to unpack elsewhere.
-
Zip a folder
Archives & compressionzip -r out.zip dir/
-r includes everything in the folder.
-
Unzip an archive
Archives & compressionunzip out.zip
Extracts into the current directory.
-
Show free disk space
System & diskdf -h
Human-readable free and used space per filesystem.
-
Find what is using space
System & diskdu -sh *
Summarised size of each item in the current directory.
-
Show free memory
System & diskfree -h
Human-readable RAM and swap usage.
-
Set an environment variable
System & diskexport NAME=value
Makes the variable available to the shell and the commands it starts.
-
See command history
System & diskhistory
Lists past commands; press Ctrl-R to search them interactively.
No commands match your search.
How it works
A searchable cheatsheet for everyday bash and Linux, organised around what you are trying to do rather than around the commands themselves. Type a goal in plain words - "search inside files", "free disk space", "kill a process" - and the matching task surfaces with the exact command. The chips group tasks by intent: files and directories, viewing and searching text, processes, permissions, networking, archives, and the system.
Each card pairs the task with the precise command and a short note on the key flags, so you can copy it with confidence instead of half-remembering the options. It favours the commands you reach for daily across any Linux or macOS shell, from ls, grep, and find to ps, tar, and ss. Everything is static and runs in your browser, so the lookup is instant and works offline once the page has loaded.
Example. Searching "search" surfaces grep -rn for finding text inside a tree of files, while filtering by the Processes chip lines up ps aux, top, kill, and lsof -i so you can find and stop a runaway program from one place.
FAQ
What is the difference between bash and the terminal?
The terminal is the window that shows text and takes your keystrokes; the shell is the program running inside it that interprets the commands you type. Bash (the Bourne Again Shell) is the most common shell on Linux, and the commands here work in it and in compatible shells such as zsh, which is the default on modern macOS. So you type bash commands into a shell, which runs inside a terminal - three layers that are easy to conflate.
What does a flag like -r or -f mean?
Flags (also called options or switches) modify how a command behaves. Single-letter flags start with one dash and can often be combined, so ls -l -a -h is the same as ls -lah. Common ones recur across tools: -r usually means recursive (descend into subdirectories), -f often means force, and -v frequently means verbose. When in doubt, run man command or command --help to see exactly what each flag does for that tool.
How do pipes and redirection work?
A pipe, written |, feeds the output of one command straight into the input of the next, so ps aux | grep node filters the process list for node. Redirection sends output to a file instead of the screen: > overwrites a file, >> appends to it, and < reads input from a file. Chaining small single-purpose commands with pipes is the heart of the Unix philosophy and the reason the shell is so powerful.
When do I need sudo?
sudo runs a single command with administrator (root) privileges, which you need for actions that affect the whole system: installing software, editing files outside your home directory, binding to ports below 1024, or changing another user's files. The rule of thumb is to use it only when a command fails with a "permission denied" error and you are sure the action is safe, rather than prefixing everything with sudo out of habit.