Linux Commands Cheat Sheet: Printable Terminal Commands for Beginners

Key Takeaway:
This cheat sheet puts the Linux terminal commands you’ll use every day on one page, grouped by the job you’re trying to do: moving around, handling files, searching, permissions, installing software and checking your network. Each group has a short note on the part beginners get wrong, and a free hands-on lesson if you want to practise. The whole thing is also a two-page PDF you can print and keep next to your keyboard.

The terminal is hard at the start for one reason: nobody tells you the words. Once you know that pwd means “where am I” and grep means “find this text”, most of it stops being mysterious. Everything below works in the terminal on Ubuntu, Linux Mint, Debian, Raspberry Pi OS and most other Linux systems. On a Mac, the file and search commands work the same way, but apt, ip, ss and free don’t exist there.

📄 Want it on paper? Download the printable cheat sheet (PDF, two pages). ItIt prints on both Letter and A4 paper.#8217;s Letter size; on A4 paper, choose It prints on both Letter and A4 paper.#8220;Fit to pageIt prints on both Letter and A4 paper.#8221; when printing.


🧭 Getting around

CommandWhat it does
pwdwhere am I
lslist files
ls -laall files, detailed
ls -lhreadable file sizes
cd direnter folder
cd ..up one level
cd ~home folder
cd -previous folder
clearclear the screen

Files whose names start with a dot are hidden, which is why plain ls misses them and ls -la doesn’t. cd - jumps straight back to wherever you were before.

Practise it: Linux Files and Folders: Find Your Way Around, a free hands-on lesson.


Files & folders

CommandWhat it does
mkdir namemake folder
mkdir -p a/b/cmake nested folders
touch filemake empty file
cp a bcopy file
cp -r a bcopy folder
mv a bmove or rename
rm filedelete, no undo
rm -r dirdelete folder
rm -i filedelete, but ask first

There is no recycle bin in the terminal. rm deletes immediately and permanently, so use rm -i, which asks before each file, while you’re learning. mv both moves and renames: moving a file to a new name in the same folder is how you rename it.

Practise it: Create, Move and Delete Files Safely, a free hands-on lesson.


Reading & editing

CommandWhat it does
cat fileprint whole file
less filescroll it (q quits)
head -20 filefirst 20 lines
tail -20 filelast 20 lines
tail -f logfollow it live
nano fileedit (Ctrl+O save, Ctrl+X exit)
wc -l filecount lines
file thingwhat type is it

Use cat for short files and less for long ones. tail -f keeps printing new lines as they’re added to a log; press Ctrl+C to stop it.


Searching

CommandWhat it does
grep "x" ffind lines in a file
grep -i "x" fignore capitals
grep -n "x" fwith line numbers
grep -r "x" .search all files below
grep -v "x" flines NOT matching
find . -name "*.txt"find by name
find . -size +10Mfind big files
which progwhere a program lives

The two get mixed up constantly: grep looks inside files for text, while find looks for files by name, size or date.

Practise it: Linux Pipes for Beginners: Search and Filter With grep, a free hands-on lesson.


Pipes & redirection

CommandWhat it does
a | bfeed a’s output to b
cmd > filesave output (overwrite)
cmd >> fileappend output
cmd 2>/dev/nulldiscard errors
cmd | tee filescreen AND file
sortsort lines
uniqremove duplicates
wc -lcount lines

One arrow replaces the whole file without asking; two arrows add to the end. Read the pipe as the word “then”: ls -la | grep log | wc -l lists the files, then keeps the ones containing “log”, then counts them.

Practise it: Linux Pipes for Beginners: Search and Filter With grep, a free hands-on lesson.


Wildcards

CommandWhat it does
*any characters
?exactly one character
[abc]any one of these
{a,b}either whole option

Before you delete with a wildcard, run the same pattern with ls first, so you see exactly which files it matches.


🔐 Permissions

CommandWhat it does
chmod +x filemake runnable
chmod 644 filenormal file
chmod 755 dirnormal folder/script
chmod 600 fileprivate to me
chown u:g filechange owner
whoamiwho am I
sudo cmdrun as admin
sudo !!redo last cmd with sudo

In the numbers, read is 4, write is 2 and execute is 1, added up for the owner, the group and everyone else: 644 is owner read+write, everyone else read only. Never fix a permission error with chmod 777, which gives everyone on the system full rights.

Practise it: Linux Permissions and sudo Explained, a free hands-on lesson.


Packages (apt)

CommandWhat it does
sudo apt updaterefresh catalogue
sudo apt upgradeupdate everything
apt search xfind a package
apt show xdetails
sudo apt install xinstall
sudo apt remove xuninstall
sudo apt autoremoveclean leftovers

apt is the package manager on Ubuntu, Linux Mint, Debian and Raspberry Pi OS. Fedora uses dnf and Arch uses pacman; the idea is the same. Run update before install so the catalogue is current.


Processes & system

CommandWhat it does
ps auxeverything running
top / htoplive view (q quits)
kill PIDstop a process
kill -9 PIDforce stop
pkill namestop by name
df -hdisk space
du -sh *size of each item
free -hmemory in use
uptimetime since reboot

Try a plain kill first, which asks the program to close itself. kill -9 stops it without letting it save anything, so keep it for programs that won’t respond.


🌐 Networking

CommandWhat it does
ip amy addresses
ip rrouting / gateway
ping -c 4 hosttest reachability
dig domainDNS lookup
curl ifconfig.memy public IP
ss -tulpnwhat’s listening
wget urldownload a file

curl ifconfig.me asks an outside service for your public IP; our What Is My IP checker shows the same thing in a browser. To read what ss -tulpn prints, see How to Check Open Ports.

Practise it: Linux Network Commands: ip, ping, curl and ss, a free hands-on lesson.


Archives

CommandWhat it does
tar -xzf f.tar.gzextract
tar -czf f.tar.gz dcreate
unzip f.zipextract a zip

The tar letters stand for extract or create, gzip compression, and file name next.


⌨️ Keyboard survival

CommandWhat it does
Tabautocomplete, use it
↑ ↓previous commands
Ctrl + Rsearch history
Ctrl + Cstop running program
Ctrl + Lclear screen
Ctrl + A / Estart / end of line
qquit man pages, less
Esc :q!escape from vim

If you remember only three things: Tab finishes what you’re typing, Ctrl+C stops anything that’s running, and sudo runs a command as administrator, which is what most “permission denied” errors on system files need.

Practise it: Your First Linux Commands, a free hands-on lesson.


Getting help

CommandWhat it does
man cmdfull manual
cmd --helpquick summary
apropos wordfind related commands

--help is the quick version and man the full manual; press q to leave it.


⚠️ The Commands That Can Hurt You

Almost everything on this page only looks at things or makes small, reversible changes. These are the exceptions, and they’re worth a second’s thought every time:

  • rm and rm -r delete for good. There’s no recycle bin and no undo.
  • Any rm -rf you copied from a website. It deletes everything it’s pointed at without asking. Never paste one from a source you don’t trust.
  • chmod 777 “fixes” a permission error by removing the protection completely. Work out who actually needs access instead.
  • > instead of >> wipes the file you’re writing to before it writes anything.
  • sudo in front of anything you don’t understand. It runs the command with full administrator rights, so a mistake can reach the whole system.

Where This Cheat Sheet Comes From

These are the two cheat-sheet pages from the back of our book Linux Terminal for Absolute Beginners: Forty Commands and the Confidence to Use Them, available on Kindle and in paperback. The book explains each command from scratch, with a “Try it” exercise in most chapters and the risky ones kept in a scratch folder where they can’t do harm. If you’d rather learn for free, the Linux and the Command Line course covers the same ground in seven hands-on lessons, some with a practice terminal in the page.


Frequently Asked Questions

Do these commands work on a Mac?

Most of them. macOS has a terminal with the same file, search, pipe and permission commands. What’s missing is the Linux-specific part: apt, ip, ss and free don’t exist on a Mac, and some options differ slightly.

What’s the difference between > and >>?

One arrow, >, replaces everything in the file with the new output. Two arrows, >>, add the new output to the end and keep what was there. When in doubt, use two.

I’m stuck inside a program and can’t get out. What do I press?

Try them in this order: q (for less, man and top), Ctrl+C (for anything still running), and Esc then :q! then Enter (for the vim editor). In nano, Ctrl+X exits.

My distribution doesn’t have apt. What do I use?

Fedora uses dnf (sudo dnf install x) and Arch uses pacman (sudo pacman -S x). Everything else on this page works the same across distributions.

Is it safe to practise these on my own computer?

The commands that only look at things, such as pwd, ls, cat, grep and ip a, can’t change anything. For the rest, practise inside /tmp, a scratch folder that most Linux systems empty when they restart, and use rm -i until deleting feels routine.


Related Reading

Scroll to Top