The Plain Picture#
Everything you'd do with paper documents: read one, flip through it, glance at the last page, make a copy, move it to another folder, throw it away, leave a sticky note pointing to it.
The Real Names and Commands#
Reading#
cat notes.txt # print the whole file (short files only)
less app.log # page through a big file: space = next page, / = search, q = quit
head -n 20 app.log # first 20 lines
tail -n 50 app.log # last 50 lines
tail -f app.log # FOLLOW: keep printing new lines as they're written — live logs. Ctrl+C to stop
wc -l app.log # count lines (wc = word count; -l = lines)
file mystery.bin # guess what kind of file it istail -f is the command you'll use most during incidents: run it, reproduce the bug, watch the error appear.
Creating, copying, moving, deleting#
touch empty.txt # create an empty file (or update an existing file's date)
mkdir notes # make a directory
mkdir -p notes/2026/biology # make every missing folder along the path
cp notes.txt backup.txt # copy a file
cp -r notes/ notes_backup/ # copy a directory and everything inside (-r = recursive)
mv notes.txt archive/ # move
mv old.txt new.txt # rename (a move within the same folder)
rm backup.txt # delete a file
rm -r notes_backup/ # delete a directory and everything insideLinks — sticky notes pointing to files#
ln -s /opt/studybuddy/releases/v42 /opt/studybuddy/currentA symbolic link (symlink) is a tiny file that points to another path — like a shortcut. ls -l shows it as
current -> /opt/studybuddy/releases/v42. Deployment tools use this trick: to switch versions, just re-point
current, which is instant, and rolling back is just as easy.
Gotchas
rmhas no Trash and no undo.rm -rf(recursive, force — no questions asked) on the wrong path is how people delete production. Before anyrm -r, runlson the exact same path first to see what it will delete. Never runrm -rf $SOMEVAR/in a script without checking the variable isn't empty — an empty variable turns it intorm -rf /.cpandmvsilently overwrite an existing file at the destination. Add-ito be asked first.caton a huge log file floods your terminal and can hang your SSH session. Useless,headortail.
Check yourself
5 questionsHow do you watch a log file live as new lines are written?
Show answerHide answer
tail -f file.log.
How do you create a/b/c/ in one command if none of them exist?
Show answerHide answer
mkdir -p a/b/c.
How do you rename draft.txt to final.txt?
Show answerHide answer
mv draft.txt final.txt.
Why do deployment tools use a symlink called current?
Show answerHide answer
Switching or rolling back versions becomes an instant re-pointing of one link.
What should you always do before rm -r some/path?
Show answerHide answer
ls some/path to see exactly what will be deleted — rm can't be undone.