Raspberry Pi: bare board to booted Linux
420-302-VA · WEEK 2 · FALL 2026

Stage 5 of 6 · Lab, on the Pi or over SSH · about 30 minutes

Use the terminal

Nearly everything you do on the Raspberry Pi this semester happens in a text terminal: installing packages, running Python, editing configuration, starting services. Twenty commands cover ninety percent of it. Learn them here, print the cheat card, and stop being afraid of the black window.

Why the terminal, and not just the desktop

  • Over SSH there is no desktop, only a terminal. That is how you will work on the Pi from the lab PC and from home.
  • The MQTT broker, the Flask web server and your control program will run as services without a screen. You will start, stop and inspect them from the command line.
  • A command can be written down, copied, repeated and checked. A sequence of clicks cannot. Your project documentation on GitHub will be full of commands.

Read the prompt

Anatomy of the prompt username at lastname-pi, colon, tilde slash iot, dollar sign, then the command ls -la username@lastname-pi:~/iot $ ls -la whoyour user wherethe hostname folder~ = home $ normal user# means root what you typethe command and its options
The prompt is a status line. When the hostname changes to your Pi's name, you are typing on the Pi. When the $ becomes #, you are root: be careful.

Commands follow one pattern: command -options arguments. Options start with - (short) or -- (long) and change how the command behaves; arguments are what it acts on. ls -la /home is the command ls, the options l (long listing) and a (show hidden files), and the argument /home.

Where am I: moving around the file system

Linux has one tree of folders (directories) starting at /, the root. There are no drive letters. Your files live in your home folder, /home/username (with your own username), which the shell abbreviates to ~.

PathWhat is there
/The root of everything
/home/username = ~Your home folder: Desktop, Documents, your projects
/boot/firmwareThe boot partition: config.txt, kernel, firmware
/etcSystem configuration files (network, SSH, services)
/var/logLog files: what the system and services have been saying
/devDevices as files: /dev/sda is a USB SSD, /dev/mmcblk0 the microSD card, /dev/ttyUSB0 a USB serial port
/usr/binInstalled programs, including python3
/tmpScratch space, emptied at reboot
$ pwd                 # print working directory: where am I?
$ ls                  # list what is here
$ ls -la              # long listing, including hidden files (names starting with .)
$ cd Documents        # go into a folder (relative to here)
$ cd /boot/firmware   # go to an absolute path
$ cd ..               # up one level
$ cd                  # back to your home folder
$ cd -                # back to the previous folder

Two keys that save your day

Tab completes file and command names (press it twice to see the options). ↑ brings back the previous command. Use both constantly; typos are the main cause of "it doesn't work".

Make, copy, move, delete

$ mkdir iot                    # make a folder
$ mkdir -p iot/week2/evidence  # make the whole path at once
$ touch notes.txt              # create an empty file (or update its timestamp)
$ cp notes.txt backup.txt      # copy
$ cp -r iot iot-copy           # copy a folder and its contents
$ mv backup.txt iot/           # move (or rename when the target is a new name)
$ rm iot/backup.txt            # delete a file: no recycle bin, no undo
$ rm -r iot-copy               # delete a folder and everything in it

rm is final

There is no trash. rm -r on the wrong folder removes it instantly. Type the path, press Tab to be sure it exists, read it, then press Enter. Never run sudo rm -r / or anything that resembles it.

Look inside files

$ cat /etc/os-release           # print the whole file
$ less /var/log/syslog          # scroll a long file: space = page, / = search, q = quit
$ head -n 5 /etc/os-release     # first 5 lines
$ tail -n 20 /var/log/syslog    # last 20 lines
$ tail -f /var/log/syslog       # follow a log as it grows; Ctrl+C to stop
$ grep -i wlan /var/log/syslog  # only lines containing "wlan" (case-insensitive)
$ lsblk > evidence/lsblk.txt    # > sends output to a file instead of the screen
$ hostname -I >> evidence/net.txt   # >> appends instead of replacing

Edit with nano

nano is a small editor that runs inside the terminal, which makes it usable over SSH. The two-letter hints at the bottom of its screen are Ctrl combinations.

$ nano notes.txt
KeysAction
Ctrl+O, then EnterWrite out (save)
Ctrl+XExit (asks to save if you changed something)
Ctrl+K / Ctrl+UCut the current line / paste it
Ctrl+WSearch
Ctrl+GHelp

Editing a system file needs root: sudo nano /boot/firmware/config.txt. For Python you will use the Thonny editor on the desktop from Week 4; over SSH, nano remains the fallback.

Who is allowed: users, sudo, permissions

Your account owns your home folder and nothing else. System files belong to root. sudo runs one command as root after asking for your password; it is the reason you never log in as root.

$ whoami                 # your username
$ sudo apt update        # run this one command as root
$ ls -l notes.txt
-rw-r--r-- 1 username username 0 Aug 31 15:02 notes.txt

Read the permission string in threes: owner rw-, group r--, others r--. r read, w write, x execute (run as a program, or enter a folder). A Python script you want to run directly needs x:

$ chmod +x blink.py      # make it executable
$ sudo chown username:username file.txt   # take ownership of a file created by root

Install software with apt

Raspberry Pi OS is Debian. Software comes as packages from Raspberry Pi's repositories, and apt fetches and installs them with their dependencies. Two steps, always in this order:

$ sudo apt update                 # 1. refresh the catalogue of available packages
$ sudo apt full-upgrade           # 2. upgrade everything already installed
$ sudo apt install htop tree      # install packages (several at once is fine)
$ apt search mosquitto            # find a package by keyword
$ apt show mosquitto              # describe it before installing
$ sudo apt remove tree            # uninstall
$ sudo apt autoremove             # drop dependencies nobody needs any more

Python libraries are a separate world (pip inside a virtual environment). That is Week 4. Do not pip install system-wide on Raspberry Pi OS; it refuses, and for good reason.

Run and stop programs

$ python3 hello.py        # run a Python script
$ python3                 # interactive Python; exit() or Ctrl+D to leave
$ ps aux | grep python    # which python processes are running? (| pipes output into grep)
$ top                     # live view of CPU and memory; q to quit (htop is nicer)
$ kill 1234               # stop the process with that PID politely
$ kill -9 1234            # stop it forcefully
  • Ctrl+C stops the program running in the foreground.
  • Ctrl+D sends "end of input": closes a Python shell or an SSH session.
  • Ctrl+Z pauses a program (fg resumes it). If a terminal seems stuck, you probably pressed this.

Network commands

$ hostname                     # the Pi's name
$ hostname -I                  # its IP address(es)
$ ip -brief address            # interfaces and their addresses
$ ping -c 3 192.168.4.1        # can I reach this address? (-c 3 = three tries)
$ ssh username@lastname-pi.local    # open a terminal on another machine
$ scp evidence.txt username@lastname-pi.local:~/    # copy a file to the Pi over SSH
$ scp username@lastname-pi.local:~/lsblk.txt .      # copy a file from the Pi to here (. = current folder)
$ ss -tlnp                     # which programs are listening on which ports (Week 3 and later)

Get help and go faster

$ ls --help             # short usage summary
$ man ls                # the full manual page; q to quit
$ history               # everything you typed; !42 re-runs line 42
$ clear                 # or Ctrl+L: clean the screen
ShortcutDoes
TabComplete a name; twice to list options
↑ / ↓Walk through previous commands
Ctrl+RSearch command history as you type
Ctrl+A / Ctrl+EJump to the start / end of the line
Ctrl+Shift+C / VCopy / paste in the terminal window (plain Ctrl+C means "stop")
Ctrl+LClear the screen

Practice: ten minutes that produce your hand-in

Do this on the Pi (or over SSH to it). It creates the evidence folder you will submit at the end of the lab.

  1. Make a home for the course

    $ cd
    $ mkdir -p iot/week2/evidence
    $ cd iot/week2/evidence
    $ pwd
  2. Capture the proof

    $ findmnt -no SOURCE / > root-device.txt
    $ lsblk -o NAME,SIZE,TYPE,MOUNTPOINTS,MODEL > lsblk.txt
    $ hostnamectl > hostname.txt
    $ head -n 3 /etc/os-release > os.txt
    $ hostname -I > ip.txt
    $ vcgencmd get_throttled > throttled.txt
  3. Write one line by hand

    Open nano station.txt, type your station number, Pi model and boot-drive label on one line, save with Ctrl+O, Enter, leave with Ctrl+X.

  4. Check and read it back

    $ ls -l
    $ cat *.txt      # * matches every file ending in .txt
  5. Bring it to the lab PC

    From the lab PC: scp -r username@lastname-pi.local:~/iot/week2/evidence . copies the whole folder next to you, ready for upload to Omnivox. (From Week 3 on, this folder goes into your GitHub repository instead.)

Cheat card

Print this section (the print stylesheet hides the navigation) or keep it open in a second tab.

pwdWhere am I
ls -laList everything here, with details
cd folder · cd .. · cdEnter a folder · go up · go home
mkdir -p a/bCreate folders, whole path at once
cp src dst · mv src dstCopy · move or rename
rm file · rm -r folderDelete, permanently
cat f · less f · tail -f fPrint a file · scroll it · follow it
grep -i word fileFind lines containing a word
nano fileEdit; Ctrl+O save, Ctrl+X exit
sudo cmdRun one command as root
chmod +x script.pyMake a file executable
sudo apt update && sudo apt full-upgradeRefresh, then upgrade all packages
sudo apt install pkgInstall a package
python3 file.pyRun a Python script
ps aux | grep name · kill PIDFind a running program · stop it
hostname -I · ip -brief addressMy IP address · all interfaces
ping -c 3 hostIs it reachable
ssh user@host.local · scp file user@host:~/Remote terminal · copy a file over SSH
findmnt -no SOURCE / · lsblkWhich device am I running from
sudo raspi-configRaspberry Pi settings menu
vcgencmd measure_temp · vcgencmd get_throttledTemperature · power/heat problems since boot
sudo reboot · sudo poweroffRestart · shut down before unplugging
cmd --help · man cmd · historyHelp · manual · what I typed
Tab · ↑ · Ctrl+C · Ctrl+D · Ctrl+LComplete · previous · stop · end input · clear

Check yourself

What is the difference between > and >>?
> writes the command's output to a file, replacing what was there. >> appends to the end of the file.
Why do you run sudo apt update before sudo apt install?
update only refreshes the catalogue of packages and versions. Without it, install may look for a version that no longer exists on the server and fail.
A terminal shows nothing when you type your password after ssh. Is it broken?
No. Linux hides password input completely, not even dots. Type it and press Enter.
What does -rwxr--r-- mean on blink.py?
The owner can read, write and execute it; the group and everyone else can only read it.
You typed rm -r iot and meant iot-copy. What now?
The folder is gone; there is no undo. This is why you keep your work in a Git repository (Week 1 and Assignment 1) and push it: the remote copy survives local mistakes.