Terminal & Shell
The black window with blinking text isn't scary — it's just a conversation with your computer, typed instead of clicked. Here's how to speak it. Every example has a Copy button so you can paste it straight into your own terminal.
Terminal vs shell — what's the difference?
The terminal = the window
A terminal emulator is the app window itself — it draws the text, handles your keyboard and colors. Examples: GNOME Terminal, Konsole, Alacritty. It emulates the physical terminals of the 1970s — hence the name.
The shell = the program inside
The shell is the program running inside the terminal that reads what you type, runs the command, and prints the result. It's the interpreter between you and the OS.
bash the default everywhere
Bourne Again SHell. Included on virtually every Linux system and server — everything you learn here works in it.
zsh the customize-everything one
Bash-compatible with better completion and plugins — famous with the Oh My Zsh framework. Default on macOS.
fish the friendly one
Friendly Interactive SHell: live auto-suggestions and syntax colors out of the box. Great once you know the basics.
Anatomy of a command
Almost every command follows the same pattern: command, then options (flags, usually starting with -),
then arguments (what to act on).
alex@pc:~$ls -la /home/alex# │ │ └─ argument: WHICH folder# │ └──────── option “long list, show hidden”# └───────────── command: “list directory contents”
Your first 13 commands
Learn these and you can navigate, manage files, and fix most beginner problems.
pwd — where am I?
Prints your current location in the file system (print working directory). The answer to “which folder am I in right now?”
alex@pc:~$pwd/home/alex
ls — list what's here
Shows the files and folders in a directory. Your most-used command by far.
alex@pc:~$ls -ladrwxr-xr-x Documentsdrwxr-xr-x Downloads-rw-r--r-- notes.txt-rw-r--r-- .hidden-file
cd — change directory
Moves you around. .. means “one level up”, ~ is your home folder, and cd alone takes you straight home.
alex@pc:~$cd Documents/projectsalex@pc:~/Documents/projects$cd ..alex@pc:~/Documents$cd ~
mkdir — make a folder
Creates new directories. The -p (parents) flag creates any missing levels in one go.
alex@pc:~$mkdir -p projects/my-first-app# creates “projects” AND “my-first-app” inside it
rm — remove (careful!)
Deletes files; add -r (recursive) for folders. There is no trash can in the terminal —
once removed, it's gone.
alex@pc:~$rm old-notes.txtalex@pc:~$rm -r old-folderalex@pc:~$rm -i maybe-keep.txtrm: remove regular file 'maybe-keep.txt'? y
rm -rf force-deletes without asking. Double-check every path before
pressing Enter — rm -rf / is the classic “delete the whole system” mistake.
cp — copy files
Copies a file (or folder with -r) to a new location or name. The original stays put.
alex@pc:~$cp notes.txt notes-backup.txtalex@pc:~$cp -r Pictures/ /media/usb/backup
mv — move or rename
One command, two jobs: move something to another folder, or rename it in place.
alex@pc:~$mv report.txt Documents/ # movealex@pc:~$mv report.txt final-report.txt # rename
cat — show a file's contents
Prints a whole text file to the screen. Great for quick peeks; for long files, less file.txt lets you scroll (press q to quit).
alex@pc:~$cat shopping.txtcoffeemore coffeecoffee beans (backup)
grep — find text inside files
A search dog for text: it prints every line that matches your pattern. Essential for digging through logs.
alex@pc:~$grep -i "error" app.log2025-01-12 10:31:02 ERROR connection refusedalex@pc:~$grep -r "password" ~/conf# -r searches every file in the folder, recursively
find — locate files by name
Where grep searches inside files, find searches for files. Give it a starting folder and a name pattern.
alex@pc:~$find ~/Documents -name "*.pdf"/home/alex/Documents/invoice-2024.pdf/home/alex/Documents/contracts/nda.pdf
sudo — do it as administrator
Stands for superuser do: run one command with admin (root) powers. It will ask for your password. You'll need it for installing software and changing system settings — more in Users & Permissions.
alex@pc:~$sudo apt update[sudo] password for alex:# note: the password stays INVISIBLE while you type — that's normal!
chmod — change permissions
Controls who can read, write or execute a file. The classic use: making a script runnable. The full system is explained in Users & Permissions.
alex@pc:~$chmod +x backup.shalex@pc:~$chmod 755 run-me.sh
man — the built-in manual
Every command ships with its own documentation. This is the most meta command of all: when in doubt, ask the manual. Press q to exit.
alex@pc:~$man lsalex@pc:~$man grep
--help, e.g. ls --help,
for a quick one-page summary instead of the full manual.
Finished this topic?
Saved locally in your browser — no account needed.