topics/04-terminal-and-shell

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.

Analogy: the terminal is the telephone; the shell is the person you talk to on the other end. You can swap phones (terminals) or change who answers (shells) — independently.

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).

command · options · arguments
alex@pc:~$ls -la /home/alex#  │    │      └─ argument: WHICH folder#  │    └──────── option “long list, show hidden”#  └───────────── command: “list directory contents”

commands/essentials

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?”

bash — pwd
alex@pc:~$pwd/home/alex

ls — list what's here

Shows the files and folders in a directory. Your most-used command by far.

bash — ls
alex@pc:~$ls -ladrwxr-xr-x  Documentsdrwxr-xr-x  Downloads-rw-r--r--  notes.txt-rw-r--r--  .hidden-file
-l · long, detailed list -a · show hidden files (they start with .) -h · human-readable sizes

cd — change directory

Moves you around. .. means “one level up”, ~ is your home folder, and cd alone takes you straight home.

bash — cd
alex@pc:~$cd Documents/projectsalex@pc:~/Documents/projects$cd ..alex@pc:~/Documents$cd ~
Pro tip: press Tab to autocomplete folder and file names — you should almost never type a full path by hand.

mkdir — make a folder

Creates new directories. The -p (parents) flag creates any missing levels in one go.

bash — mkdir
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.

bash — rm
alex@pc:~$rm old-notes.txtalex@pc:~$rm -r old-folderalex@pc:~$rm -i maybe-keep.txtrm: remove regular file 'maybe-keep.txt'? y
Danger zone: 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.

bash — cp
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.

bash — mv
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).

bash — cat
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.

bash — grep
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.

bash — find
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.

bash — sudo
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.

bash — chmod
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.

bash — man
alex@pc:~$man lsalex@pc:~$man grep
Shorter alternative: most commands answer to --help, e.g. ls --help, for a quick one-page summary instead of the full manual.
Try all of this right now — no Linux required. Every command on this page works in the live Practice Terminal: a sandbox built into this site, running entirely in your browser. Copy a command, paste it there, and see the output for yourself.
Finished this topic?

Saved locally in your browser — no account needed.