Linux Commands Cheat Sheet

The Linux commands developers actually use daily — navigation, permissions, piping, processes, and networking — with real examples, common mistakes, and a searchable quick reference.

runs locally on your browser. Your data never leaves your device.
13 sections
55 commands
Searchable quick reference
100% offline

Viewing & Editing

Getting a file's contents onto your screen — the whole thing, part of it, or live as it changes.

cat file.txt
Essential

Prints a file's entire contents straight to the terminal. Great for short files or piping into another command; less great for anything long enough to scroll past.

less file.txt
Essential

Pages through a file interactively — arrow keys or space to scroll, / to search, q to quit. Unlike cat, it doesn't load the whole file into your terminal's scrollback at once.

head -n 20 file.txt tail -n 20 file.txt
Essential

Show just the first (head) or last (tail) N lines of a file. The default, with no -n, is 10 lines.

tail -f app.log
Essential

Follows a file's contents live as new lines are appended — the standard way to watch a server's log file update in real time while you reproduce a bug.

touch newfile.txt
Handy

Creates an empty file if it doesn't already exist, or just updates its last-modified timestamp if it does.

nano file.txt
Handy

Opens a file in a simple, beginner-friendly terminal editor with its shortcuts printed on screen — the safe default before you reach for vim.

cat vs. less
cat is for piping into another command or glancing at a short file; less is for actually reading something — it pages, it searches, and it doesn't flood your terminal with thousands of lines at once the way cat does on a large file.

Permissions & Ownership

The part of Linux that trips up almost everyone the first time — three sets of three permissions, and one number for each set.

ls -l
Essential

Shows a permission string like -rwxr-xr-- next to each file: file type, then three permission triplets for owner, group, and everyone else, in that order.

chmod 755 script.sh
Essential

Sets exact permissions using octal notation. Each digit is read+write+execute added up: read=4, write=2, execute=1 — so 7 (4+2+1) is full access, 5 (4+1) is read+execute, and 755 means the owner gets everything while everyone else can read and run it, not modify it.

755 → owner: rwx (7) group: r-x (5) others: r-x (5)

chmod +x script.sh
Essential

Adds execute permission without touching any of the other permission bits — the usual, minimal fix for 'permission denied' when running a script you just wrote or downloaded.

chown user:group file.txt
Handy

Changes a file's owner and group in one command. Usually requires sudo unless you already own the file and are only changing its group.

sudo apt update
Essential

Runs a single command with elevated (root) privileges. Prompts for your own password, not root's, and logs exactly who ran what.

chmod 777 is a security hole disguised as a quick fix
777 gives read, write, and execute to the owner, the group, and literally everyone else on the system. It "fixes" a permission error the same way removing a lock fixes a jammed door. The real fix is almost always chmod +x, or correcting who owns the file — not opening it up to everyone.

Piping, Redirection & Text Processing

The part that turns a shell from a slower file browser into something genuinely powerful — chaining small, single-purpose commands together.

cmd1 | cmd2
Essential

Pipes the output of cmd1 directly into the input of cmd2, with no temp file in between. The core idea behind almost every 'clever' one-liner you'll see.

ps aux | grep nginx cat access.log | grep 404 | wc -l

cmd > file.txt
Essential

Redirects a command's output to a file, completely overwriting whatever was there before — with no confirmation.

cmd >> file.txt
Handy

Redirects output to a file, appending to the end instead of overwriting it — the one-character difference from > that matters enormously.

cmd 2> errors.txt
Advanced

Redirects just the error output (stderr) to a file, separately from normal output (stdout). Use 2>&1 to merge stderr into wherever stdout is already going.

grep -i "error" app.log
Essential

Searches a file's lines for a pattern. -i ignores case, -r searches every file in a directory recursively, -v inverts the match (show lines that don't match).

sort names.txt | uniq
Handy

Sorts lines alphabetically, then collapses adjacent duplicate lines into one. uniq only removes duplicates that are already next to each other, which is exactly why it's almost always paired with sort first.

wc -l file.txt
Handy

Counts lines in a file, or in piped input. -w counts words instead, -c counts bytes.

Overwrites silently, every time
There's no confirmation and no undo. A stray > where you meant >> — especially inside a script running on a schedule — has erased more than one person's entire log file in a single character's mistake.
Pro trick
grep -c "pattern" file.txt counts matching lines directly — no need to pipe the result into wc -l separately.

Processes & Jobs

What's actually running, and how to control it once it is.

ps aux
Essential

Lists every running process on the system, with owner, CPU/memory usage, and the exact command that started it.

top
Essential

A live, auto-refreshing view of running processes sorted by resource usage. htop is a friendlier drop-in replacement if it's installed.

kill 12345 kill -9 12345
Essential

Plain kill asks a process to terminate gracefully (sends SIGTERM, giving it a chance to clean up). kill -9 force-kills it immediately, skipping that cleanup entirely.

long-running-command &
Handy

Runs a command in the background, immediately freeing up the terminal for something else.

jobs fg bg
Handy

jobs lists background jobs in the current shell session; fg brings one back to the foreground; bg resumes a paused job in the background.

nohup long-script.sh &
Advanced

Runs a command in the background that keeps running even after you close the terminal or log out — without nohup, a background job is killed the moment its parent shell exits.

Reach for kill before kill -9
kill -9 skips a process's own cleanup logic entirely — open files, in-progress writes, temp files don't get a chance to close cleanly. Try a plain kill first and only escalate if the process genuinely won't respond.
Tip
Ctrl+Z pauses (suspends) the current foreground job without killing it. Follow with bg to resume it in the background, freeing your terminal without losing the process's progress.

Networking

Talking to other machines — checking they're reachable, moving files, and getting a shell on them.

ping example.com
Essential

Sends repeated packets to a host and reports whether, and how fast, it responds — usually the very first thing to check when something 'isn't working.'

curl https://example.com
Essential

Fetches a URL's response and prints it to the terminal. curl -I fetches just the headers, curl -o file.html saves the response straight to a file instead of printing it.

wget -c https://example.com/file.zip
Handy

Downloads a file from a URL directly to disk. -c resumes an interrupted download instead of starting over from zero.

ssh user@host
Essential

Opens a secure remote shell on another machine — the standard way to log into and work on a remote server.

scp file.txt user@host:/remote/path/
Handy

Copies a file to (or from) a remote machine over SSH, using the same authentication as an ssh login.

ip addr
Handy

Shows this machine's network interfaces and their IP addresses. ip addr is the modern command; the older ifconfig still works on many systems but is considered deprecated.

curl vs. wget, in one line each
curl is built for talking to APIs and printing or piping a response; wget is built for downloading files to disk, especially large or resumable ones. Plenty of overlap between them, but that's the intent each was designed around.

Disk & System Info

What's actually on this machine, and how much of it is left.

df -h
Essential

Shows disk space usage for every mounted filesystem, in human-readable sizes (GB/MB) instead of raw byte counts.

du -sh /path/to/dir
Essential

Shows the total size of a directory. Without -s, du recursively lists the size of every subdirectory too, which gets noisy fast on a big tree.

free -h
Handy

Shows total, used, and available RAM and swap, in human-readable sizes.

uname -a
Handy

Prints system information: kernel name, hostname, kernel version, and architecture, all in one line.

systemctl status nginx
Advanced

Checks whether a systemd-managed service is running, and shows its recent log output right in the same command.

journalctl -u nginx -f
Advanced

Follows a systemd service's logs live — the systemd-managed equivalent of tail -f on a plain log file.

Pro trick
du -sh * | sort -rh gives an instant "what's actually taking up space here" breakdown of the current directory, largest first.

Packages & Archives

Installing software and bundling files — the exact command name changes by distro, the underlying idea doesn't.

sudo apt update && sudo apt install curl
Essential

On Debian/Ubuntu: refresh the package list, then install a package. dnf install on Fedora/RHEL, pacman -S on Arch — the concept (refresh index, then install) is identical everywhere.

sudo apt remove curl
Handy

Uninstalls a package. apt purge additionally removes its configuration files, apt remove leaves them in place.

tar -czvf archive.tar.gz folder/
Handy

Creates a compressed archive: c=create, z=gzip compression, v=verbose (list files as it works), f=the filename that follows.

tar -xzvf archive.tar.gz
Handy

Extracts a .tar.gz archive back into files — same flags as creating one, but x for extract instead of c for create.

unzip archive.zip
Handy

Extracts a .zip archive into the current directory.

apt is one example among several
The commands here assume Debian/Ubuntu's apt since it's the most common. dnf (Fedora/RHEL), pacman (Arch), apk (Alpine), and others differ in exact syntax but do the same three things: refresh the package index, install, and remove.

Environment & Shell Config

The settings and shortcuts that make your own terminal feel like yours.

whoami
Essential

Prints the currently logged-in username.

echo $PATH
Handy

Prints the PATH variable — the list of directories the shell searches, in order, whenever you type a command name. If a command isn't found, checking this is the first thing to do.

export API_KEY=abc123
Handy

Sets an environment variable for the current shell session and everything launched from it. A plain API_KEY=abc123 without export only sets it for the current shell, invisible to anything it runs.

alias ll='ls -la'
Handy

Creates a shorthand for a longer command. Add it to your shell config file (~/.bashrc or ~/.zshrc) to make it permanent across sessions instead of just the current one.

source ~/.bashrc
Advanced

Re-loads your shell config file into the current session, so a change you just made (a new alias, a PATH update) takes effect without closing and reopening the terminal.

history | grep docker
Advanced

Searches your command history for a previous command you half-remember typing.

Pro trick
Ctrl+R searches your command history interactively as you type, right in the prompt — often faster than history | grep for a command you typed recently.

Quick Reference

Already comfortable in a terminal — just blanked on a flag? Search instead of scrolling.

pwd

Print the current working directory's full path

ls -la

List all files, including hidden ones, in long format

cd ~

Change to your home directory

cd -

Change back to the previous directory

mkdir -p

Create a directory, including missing parent directories

cp -r

Copy a directory recursively

mv

Move or rename a file or directory

rm -rf

Recursively force-delete with no confirmation, no undo

find . -name

Search a directory tree for files matching a name pattern

cat

Print a file's entire contents to the terminal

less

Page through a file interactively without loading it all at once

head -n

Show just the first N lines of a file

tail -f

Follow a file's contents live as new lines are appended

touch

Create an empty file, or update its modified timestamp

ls -l

Show permissions, owner, and group alongside each file

chmod 755

Set exact permissions using octal notation

chmod +x

Add execute permission without touching other bits

chown user:group

Change a file's owner and group

sudo

Run a single command with elevated privileges

|

Pipe one command's output into the next command's input

>

Redirect output to a file, overwriting it completely

>>

Redirect output to a file, appending to the end

2>

Redirect just the error output (stderr) to a file

grep -i

Search lines for a pattern, case-insensitively

grep -r

Search every file in a directory tree recursively

sort | uniq

Sort lines, then collapse adjacent duplicates

wc -l

Count lines in a file or piped input

ps aux

List every running process with owner, usage, and command

top

Live, auto-refreshing view of processes by resource usage

kill

Ask a process to terminate gracefully

kill -9

Force-kill a process immediately, skipping cleanup

&

Run a command in the background

jobs / fg / bg

List, foreground, or resume background jobs

nohup

Keep a background command running after logout

ping

Check whether a host responds, and how fast

curl

Fetch a URL's response and print or save it

wget

Download a file from a URL, with resume support

ssh user@host

Open a secure remote shell on another machine

scp

Copy a file to or from a remote machine over SSH

ip addr

Show this machine's network interfaces and IP addresses

df -h

Show disk space usage in human-readable sizes

du -sh

Show a directory's total size

free -h

Show RAM and swap usage in human-readable sizes

uname -a

Print kernel, hostname, and architecture info

systemctl status

Check whether a systemd service is running

journalctl -u -f

Follow a systemd service's logs live

apt install

Install a package on Debian/Ubuntu

tar -czvf

Create a gzip-compressed tar archive

tar -xzvf

Extract a .tar.gz archive

unzip

Extract a .zip archive

whoami

Print the currently logged-in username

echo $PATH

Print the list of directories the shell searches for commands

export VAR=value

Set an environment variable for this session and its children

alias

Create a shorthand for a longer command

history | grep

Search your command history for something you typed before

55 of 55 commands

Common Use Cases

Real situations, not just isolated commands — the exact sequence that gets you through each one.

You need to find every file over 100MB eating up disk space

Search from the root, filter to files only, and suppress permission-error noise:

  1. find / -type f -size +100M 2>/dev/null

You want to watch a log file update live while reproducing a bug

Follow the file, then trigger the bug in another window:

  1. tail -f /var/log/app.log

A script you just wrote fails with 'Permission denied'

The execute bit almost certainly isn't set yet:

  1. chmod +x script.sh
  2. ./script.sh

You need to free up disk space and don't know what's using it

List the current directory's contents by size, largest first:

  1. du -sh * | sort -rh | head

A process is stuck and won't respond to Ctrl+C

Find its PID, ask it to stop, then force it if it ignores you:

  1. ps aux | grep process-name
  2. kill PID
  3. kill -9 PID

You need to copy a whole project to a remote server

Archive it locally, transfer the single file, then extract it remotely:

  1. tar -czvf project.tar.gz project/
  2. scp project.tar.gz user@host:~/
  3. ssh user@host tar -xzvf project.tar.gz

Debugging & Troubleshooting

The exact text a shell prints when something's wrong, decoded.

bash: command: command not found

Either the program genuinely isn't installed (install it with your package manager), or it's installed somewhere not listed in $PATH. Check which command first — if it prints nothing, that's your answer.

which command
Permission denied when running ./script.sh

The execute bit isn't set on the file. This is unrelated to file ownership or sudo — it's specifically the x permission.

chmod +x script.sh
No space left on device, but df -h shows free space

You may be out of inodes rather than bytes — a filesystem can run out of the 'slots' for file entries even with plenty of raw space left. Check inode usage, and also check for a large file that's been deleted but is still held open by a running process (which keeps the space allocated until that process exits).

df -i
A command hangs and Ctrl+C doesn't stop it

Try Ctrl+Z to suspend it instead, then kill it by job number from the same shell — or open a second terminal, find its PID with ps aux, and kill it directly.

kill -9 %1
rm: cannot remove 'folder': Is a directory

Plain rm only removes files. Add -r to remove a directory and everything inside it (or -rf to also skip the confirmation prompts).

rm -r folder/
sudo: command not found, right after sudo apt install-ing it

Your shell cached the list of available commands from before the install. Open a new terminal, or clear the shell's command lookup cache in the current one.

hash -r

Things to Remember

If you forget everything else on this page, keep these.

  • ls -la and pwd are your two most common orientation commands — run them any time you're unsure where you are.
  • rm -rf has no undo. Read the path twice, especially inside a script or behind a variable, before running it.
  • | chains commands together; > overwrites a file; >> appends to it — mixing up > and >> is one of the most common footguns here.
  • chmod +x is almost always the fix for 'permission denied' on a script you just wrote or downloaded.
  • kill before kill -9 — give a process the chance to clean up before you force it to stop.
  • tail -f is how you watch a log file live; less is how you actually read one.
  • sudo re-runs one command as root — it doesn't change who you are for the rest of the session.
  • Package manager commands differ by distro (apt, dnf, pacman), but update/install/remove mean the same thing everywhere.
  • history | grep or Ctrl+R finds a command you've already typed, faster than scrolling back through your session.

Common Use Cases

Recall the exact chmod octal or flag before fixing a 'permission denied' error on a script you just wrote
Look up the difference between kill and kill -9 before force-stopping a process that won't respond
Reference the right redirection operator — > vs >> — before accidentally overwriting a file you meant to append to
Search the quick-reference table for a command's exact flags instead of digging through a man page

About Linux Commands Cheat Sheet

man pages are technically complete and practically useless the first fifty times you read one — they tell you every flag a command accepts, not which three you'll actually reach for or why chmod 755 is the one you want instead of chmod 777. Most Linux cheat sheets have the same problem: an alphabetized dump of commands and flags, with no sense of which ones come up constantly versus which ones you'll use twice a year.

This one is organized the way you actually build up terminal fluency — starting with navigating and manipulating files (the first thing you do in any terminal), through permissions and ownership (the thing that trips up almost every beginner at least once), into piping, redirection, and text processing (the part that actually makes a shell powerful instead of just a slower file browser), and on through processes, networking, disk and system info, package management, and shell environment configuration.

Every section calls out the mistakes that actually cause damage or wasted time: rm -rf with no undo and no trash bin, a stray > instead of >> silently overwriting a file you meant to append to, chmod 777 used as a "quick fix" that's actually a security hole, kill -9 skipping a process's own cleanup instead of asking it to shut down gracefully. There's a searchable quick reference for the moment you already know roughly what you want, and a troubleshooting section built around the actual error text a shell prints — permission denied, command not found, no space left on device — not a paraphrase of it.

The commands here are standard POSIX/GNU utilities — they work the same in any Linux terminal, in WSL, and mostly on macOS (whose built-in versions of a few tools like sed and tar are BSD variants with slightly different flags, called out where it matters). And like every tool on AllCoreKit, this page itself is fully static: no command runs anywhere, nothing you search for is sent anywhere or logged, and it works completely offline once loaded.

Frequently Asked Questions