quick referencealways safe to read, labelled when not

The cheat sheet

Everyday commands with a note on what each one actually does. Commands marked read-only can't change anything. Run those as freely as you like.

Getting your bearings

pwd

Where am I? Prints the folder you're standing in. Read-only.

ls -lh

What's here? Lists files with sizes in human units (the h). Read-only.

cd ~/Downloads

Go somewhere. ~ is shorthand for your home folder. cd .. goes up; plain cd goes home.

man cp

Read the manual for any command (here: cp). Scroll with arrows, leave with q. Read-only.

Files

cp file.txt file-backup.txt

Copy. Source first, destination second. Add -r to copy a whole folder.

mv file.txt ~/Documents/

Move, and also rename: mv old.txt new.txt. Same verb, both jobs.

rm file.txt

Delete. Permanently. No recycle bin. Read the filename twice; there is no undo.

find ~ -name "*.pdf" -mtime -7

Find files: every PDF in your home folder modified in the last 7 days. Read-only.

grep -ri "invoice" ~/Documents

Search inside files for a word, ignoring case (i), through subfolders (r). Read-only.

Installing & updating

sudo apt update && sudo apt upgrade

Update everything (Ubuntu/Mint/Debian): refresh the catalog, then install what's new. Asks for your password.

sudo apt install vlc

Install a program by name (here: VLC). sudo apt remove vlc uninstalls it.

sudo dnf upgrade

Fedora's version of update-everything. Install with sudo dnf install vlc.

apt search "image editor"

Find software when you don't know the package name. Read-only. Searching installs nothing.

Disks & space

df -h

How full are my drives? Shows each disk and its free space in human units. Read-only.

du -sh ~/Downloads

How big is this folder? One summarized (s), human-readable (h) total. Read-only.

lsblk

What drives are plugged in? Lists disks, partitions and where they're mounted. Handy for USB sticks. Read-only.

Network

ping -c 4 freelinuxhelp.com

Am I online? Sends 4 test packets. Replies = you're connected; unknown host with working Wi-Fi = DNS trouble. Read-only.

nmcli device wifi list

What networks can I see? Asks NetworkManager for nearby Wi-Fi. Read-only. (Wi-Fi missing entirely? Ticket #0001.)

ip a

What's my IP address? Lists network interfaces and their addresses. Read-only.

Processes & power

top

What's eating my CPU? Live view of running programs. Leave with q. Read-only.

pkill -f firefox

Force-quit a frozen app by name. Unsaved work in that app is lost. It's the "end task" of last resort.

systemctl status NetworkManager

Is a service running? Health report for any background service. Read-only; swap in restart (with sudo) to kick it.

sudo reboot

Restart the machine. sudo poweroff shuts it down instead. Save your work first.

When it breaks

journalctl -p err -b

Show me the errors (-p err) from this boot (-b). The system's diary. Read-only, and the first thing to check when something misbehaves.

dmesg | tail -n 30

What did the kernel just say? The last 30 hardware-level messages. Plug in the misbehaving device, then run this. Needs sudo on some distros. Read-only.

uname -r

Which kernel am I on? Useful when a forum asks. And they will ask. Read-only.

reset

Terminal showing garbage? Redraws it clean. Cosmetic, always safe.