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.
Viewing & Editing
Getting a file's contents onto your screen — the whole thing, part of it, or live as it changes.
cat file.txtPrints 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.txtPages 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.txtShow just the first (head) or last (tail) N lines of a file. The default, with no -n, is 10 lines.
tail -f app.logFollows 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.txtCreates an empty file if it doesn't already exist, or just updates its last-modified timestamp if it does.
nano file.txtOpens a file in a simple, beginner-friendly terminal editor with its shortcuts printed on screen — the safe default before you reach for vim.
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 -lShows 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.shSets 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.shAdds 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.txtChanges 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 updateRuns a single command with elevated (root) privileges. Prompts for your own password, not root's, and logs exactly who ran what.
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 | cmd2Pipes 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.txtRedirects a command's output to a file, completely overwriting whatever was there before — with no confirmation.
cmd >> file.txtRedirects output to a file, appending to the end instead of overwriting it — the one-character difference from > that matters enormously.
cmd 2> errors.txtRedirects 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.logSearches 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 | uniqSorts 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.txtCounts lines in a file, or in piped input. -w counts words instead, -c counts bytes.
> 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.Processes & Jobs
What's actually running, and how to control it once it is.
ps auxLists every running process on the system, with owner, CPU/memory usage, and the exact command that started it.
topA 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 12345Plain 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 &Runs a command in the background, immediately freeing up the terminal for something else.
jobs fg bgjobs 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 &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.
Networking
Talking to other machines — checking they're reachable, moving files, and getting a shell on them.
ping example.comSends 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.comFetches 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.zipDownloads a file from a URL directly to disk. -c resumes an interrupted download instead of starting over from zero.
ssh user@hostOpens 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/Copies a file to (or from) a remote machine over SSH, using the same authentication as an ssh login.
ip addrShows 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.
Disk & System Info
What's actually on this machine, and how much of it is left.
df -hShows disk space usage for every mounted filesystem, in human-readable sizes (GB/MB) instead of raw byte counts.
du -sh /path/to/dirShows 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 -hShows total, used, and available RAM and swap, in human-readable sizes.
uname -aPrints system information: kernel name, hostname, kernel version, and architecture, all in one line.
systemctl status nginxChecks whether a systemd-managed service is running, and shows its recent log output right in the same command.
journalctl -u nginx -fFollows a systemd service's logs live — the systemd-managed equivalent of tail -f on a plain log file.
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 curlOn 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 curlUninstalls a package. apt purge additionally removes its configuration files, apt remove leaves them in place.
tar -czvf archive.tar.gz folder/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.gzExtracts a .tar.gz archive back into files — same flags as creating one, but x for extract instead of c for create.
unzip archive.zipExtracts a .zip archive into the current directory.
Environment & Shell Config
The settings and shortcuts that make your own terminal feel like yours.
whoamiPrints the currently logged-in username.
echo $PATHPrints 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=abc123Sets 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'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 ~/.bashrcRe-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 dockerSearches your command history for a previous command you half-remember typing.
Quick Reference
Already comfortable in a terminal — just blanked on a flag? Search instead of scrolling.
pwdPrint the current working directory's full path
ls -laList all files, including hidden ones, in long format
cd ~Change to your home directory
cd -Change back to the previous directory
mkdir -pCreate a directory, including missing parent directories
cp -rCopy a directory recursively
mvMove or rename a file or directory
rm -rfRecursively force-delete with no confirmation, no undo
find . -nameSearch a directory tree for files matching a name pattern
catPrint a file's entire contents to the terminal
lessPage through a file interactively without loading it all at once
head -nShow just the first N lines of a file
tail -fFollow a file's contents live as new lines are appended
touchCreate an empty file, or update its modified timestamp
ls -lShow permissions, owner, and group alongside each file
chmod 755Set exact permissions using octal notation
chmod +xAdd execute permission without touching other bits
chown user:groupChange a file's owner and group
sudoRun 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 -iSearch lines for a pattern, case-insensitively
grep -rSearch every file in a directory tree recursively
sort | uniqSort lines, then collapse adjacent duplicates
wc -lCount lines in a file or piped input
ps auxList every running process with owner, usage, and command
topLive, auto-refreshing view of processes by resource usage
killAsk a process to terminate gracefully
kill -9Force-kill a process immediately, skipping cleanup
&Run a command in the background
jobs / fg / bgList, foreground, or resume background jobs
nohupKeep a background command running after logout
pingCheck whether a host responds, and how fast
curlFetch a URL's response and print or save it
wgetDownload a file from a URL, with resume support
ssh user@hostOpen a secure remote shell on another machine
scpCopy a file to or from a remote machine over SSH
ip addrShow this machine's network interfaces and IP addresses
df -hShow disk space usage in human-readable sizes
du -shShow a directory's total size
free -hShow RAM and swap usage in human-readable sizes
uname -aPrint kernel, hostname, and architecture info
systemctl statusCheck whether a systemd service is running
journalctl -u -fFollow a systemd service's logs live
apt installInstall a package on Debian/Ubuntu
tar -czvfCreate a gzip-compressed tar archive
tar -xzvfExtract a .tar.gz archive
unzipExtract a .zip archive
whoamiPrint the currently logged-in username
echo $PATHPrint the list of directories the shell searches for commands
export VAR=valueSet an environment variable for this session and its children
aliasCreate a shorthand for a longer command
history | grepSearch 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:
- 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:
- tail -f /var/log/app.log
A script you just wrote fails with 'Permission denied'
The execute bit almost certainly isn't set yet:
- chmod +x script.sh
- ./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:
- 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:
- ps aux | grep process-name
- kill PID
- 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:
- tar -czvf project.tar.gz project/
- scp project.tar.gz user@host:~/
- 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 foundEither 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 commandPermission denied when running ./script.shThe 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.shNo space left on device, but df -h shows free spaceYou 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 -iA command hangs and Ctrl+C doesn't stop itTry 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 %1rm: cannot remove 'folder': Is a directoryPlain 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 itYour 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 -rThings 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
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
Related Tools
View all Cheat SheetsGit Cheat Sheet
The Git commands developers actually use daily, organized by workflow — branching, rebasing, undoing mistakes, and recovery — with real examples and a searchable quick reference.
Regex Cheat Sheet
The regex syntax developers actually reach for — anchors, character classes, groups, and lookaround — with real patterns, common mistakes, and a searchable quick reference.
Prompt Engineering Cheat Sheet
The prompt patterns that actually change LLM output — anatomy, few-shot, chain-of-thought, and structured formatting — with real examples, pitfalls, and a searchable quick reference.