IoTPSUT IoT Engineering StudioPrincess Sumaya University for Technology · Dr. Mohammad Alja’afreh
Foundations · Command Center
IoT Programming and Applications
Master the Linux terminal.
Learn the commands you will use in every IoT lab. Copy exact examples into the correct terminal, or practice safely in the browser before touching real files.
Run wsl --list --verbose, install or stop Ubuntu here.
UBUNTU · Bash
student@ubuntu:~$
Run cd, ls, sudo apt, python and service commands here.
PYTHON · REPL
>>>
Only Python statements here. Type exit() to return to Bash.
Do not copy prompt symbols. In VS Code, choose Terminal → New Terminal inside the WSL workspace; check the lower-left remote indicator. Use a separate Windows PowerShell window for WSL management. Ctrl+C stops most foreground programs; Tab completes names, ↑ recalls a previous command, Ctrl+L clears the screen.
Interactive learning · simulated filesystem
Virtual command terminal
Practice navigation, files, WSL launch and Python commands. This browser model never executes commands on your computer. The paths and outputs are examples, not your actual machine.
● ● ●Ubuntu BashSIMULATED
Dr. Mohammad · terminal coach
Try pwd to identify the current directory. Then use ls to see its contents.
Only a documented subset is supported. Package installs, destructive commands and real services are not executed in this simulator.
Two daily workflows
Open and run a real Python lab
1. Open Windows PowerShell and start Ubuntu:
Windows PowerShell
wsl-dUbuntu-24.04
✓ Expected: The selected Linux shell opens; on first launch complete account creation. The prompt ends in $. No physical board is connected by this command.
2. In Ubuntu, activate the installed toolkit and run Lab 29:
Ubuntu Bash
source ~/psut-wsl/activate.sh
cd ~/psut-wsl/labs/python/lab29
pwdlspython blink_gpiozero.py
✓ Expected: The fake GPIO17 output alternates HIGH/LOW every 0.5 seconds. Press Ctrl+C to stop.Expected result for each action (5)
source ~/psut-wsl/activate.shThe toolkit virtual environment is selected in this terminal, usually with (.venv) in the prompt. Verify which python points into ~/psut-wsl/.venv.
cd ~/psut-wsl/labs/python/lab29Normally no output. pwd should show the requested directory. A missing path produces an error; do not continue until corrected.
pwdAn absolute Linux path appears, matching the directory selected in the preceding step.
lsThe requested files/directories are listed; compare names and permissions with the guide. An empty directory can produce no output.
python blink_gpiozero.pyThe fake GPIO17 output alternates HIGH/LOW every 0.5 seconds. Press Ctrl+C to stop.
3. Press Ctrl+C to stop. To reopen the workspace use cd ~/psut-wsl then code ..
Print the absolute path of the current working directory.
Ubuntu Bash
pwd
✓ Expected: An absolute Linux path appears, matching the directory selected in the preceding step.
Check: A path such as /home/student.
List files and folders
Show visible entries in the current directory.
Ubuntu Bash
ls
✓ Expected: The requested files/directories are listed; compare names and permissions with the guide. An empty directory can produce no output.
Check: Folder and file names.
Show details and hidden files
-l shows permissions, owner, size and time; -a includes hidden entries.
Ubuntu Bash
ls-la
✓ Expected: The requested files/directories are listed; compare names and permissions with the guide. An empty directory can produce no output.
Check: A detailed listing including . and ..
Go to your home directory
~ expands to your Linux home. cd without an argument does the same.
Ubuntu Bash
cd ~
✓ Expected: Normally no output. pwd should show the requested directory. A missing path produces an error; do not continue until corrected.
Check: pwd prints your home path.
Open the toolkit directory
An absolute path expressed using ~ works from any directory. Copy the toolkit first.
Ubuntu Bash
cd ~/psut-wsl
✓ Expected: Normally no output. pwd should show the requested directory. A missing path produces an error; do not continue until corrected.
Check: pwd ends in /psut-wsl.
Enter a child directory
A relative path is resolved from the current folder. First enter ~/psut-wsl.
Ubuntu Bash
cd labs
✓ Expected: Normally no output. pwd should show the requested directory. A missing path produces an error; do not continue until corrected.
Check: pwd ends in /psut-wsl/labs.
Go up one level
.. means the parent directory.
Ubuntu Bash
cd ..
✓ Expected: Normally no output. pwd should show the requested directory. A missing path produces an error; do not continue until corrected.
Check: pwd shows the parent path.
Return to the previous directory
The shell remembers the preceding working directory.
Ubuntu Bash
cd -
✓ Expected: Normally no output. pwd should show the requested directory. A missing path produces an error; do not continue until corrected.
Check: The previous directory is printed.
Go to the filesystem root
/ is the top of Linux, not your personal home.
Ubuntu Bash
cd /
✓ Expected: Normally no output. pwd should show the requested directory. A missing path produces an error; do not continue until corrected.
Check: pwd prints /.
Show directory structure
Show two levels of the directory tree. If missing, install tree with apt.
Ubuntu Bash
tree -L2 .
✓ Expected: An indented directory tree.
Check: An indented directory tree.
Find Windows user folders
WSL mounts the Windows C drive under /mnt/c.
Ubuntu Bash
ls /mnt/c/Users
✓ Expected: The requested files/directories are listed; compare names and permissions with the guide. An empty directory can produce no output.
Check: Windows user directories; names vary.
Open current folder in Windows Explorer
The dot passes the current directory to Windows Explorer.
Ubuntu Bash
explorer.exe .
✓ Expected: Windows File Explorer opens the current Linux folder; no terminal output is normally required.
Check: A File Explorer window opens.
Jump to the LED lab
Use the exact toolkit path rather than navigating one folder at a time.
Ubuntu Bash
cd ~/psut-wsl/labs/python/lab29
✓ Expected: Normally no output. pwd should show the requested directory. A missing path produces an error; do not continue until corrected.
Check: pwd ends in /lab29.
Ubuntu Bash
02 · Files & directories
Create a practice directory
-p creates missing parents and does not fail if the directory exists.
Ubuntu Bash
mkdir-p ~/linux-practice
✓ Expected: Normally silent. The requested directory exists afterward; verify with ls -d.
Check: ls ~/linux-practice succeeds.
Enter the practice directory
Use this folder for all examples in this section.
Ubuntu Bash
cd ~/linux-practice
✓ Expected: Normally no output. pwd should show the requested directory. A missing path produces an error; do not continue until corrected.
Check: pwd ends in /linux-practice.
Make a subdirectory
Create a child named Documents.
Ubuntu Bash
mkdir-p Documents
✓ Expected: Normally silent. The requested directory exists afterward; verify with ls -d.
Check: ls shows Documents.
Create an empty file
Creates a file if missing; otherwise updates its timestamp.
Ubuntu Bash
touch test.txt
✓ Expected: ls -l test.txt shows the file.
Check: ls -l test.txt shows the file.
Write text to a file
> creates or overwrites test.txt. Use only your practice file.
Ubuntu Bash
echo"Hello IoT" > test.txt
✓ Expected: cat test.txt prints Hello IoT.
Check: cat test.txt prints Hello IoT.
Read the file
Print its full contents.
Ubuntu Bash
cat test.txt
✓ Expected: Hello IoT if you completed the previous example.
Check: Hello IoT if you completed the previous example.
Append text
>> adds to the end instead of replacing existing content.
Ubuntu Bash
echo"Second line" >> test.txt
✓ Expected: cat shows both lines.
Check: cat shows both lines.
Copy a file
Copies the source to the destination; an existing destination can be overwritten.
Ubuntu Bash
cp test.txt backup.txt
✓ Expected: ls shows both files.
Check: ls shows both files.
Rename or move a file
Rename the copy, leaving test.txt unchanged.
Ubuntu Bash
mv backup.txt notes.txt
✓ Expected: ls shows notes.txt, not backup.txt.
Check: ls shows notes.txt, not backup.txt.
Edit a file in the terminal
Edit text; Ctrl+O then Enter saves; Ctrl+X exits.
Ubuntu Bash
nano test.txt
✓ Expected: cat shows your saved changes.
Check: cat shows your saved changes.
View the first five lines
Useful for checking the start of a CSV or log.
Ubuntu Bash
head -n5 test.txt
✓ Expected: Up to five lines appear.
Check: Up to five lines appear.
View the last five lines
Useful for checking recent records.
Ubuntu Bash
tail -n5 test.txt
✓ Expected: Up to five lines appear.
Check: Up to five lines appear.
Find matching text
-n shows matching line numbers.
Ubuntu Bash
grep-n"IoT" test.txt
✓ Expected: Lines containing IoT, or no output if no match.
Check: Lines containing IoT, or no output if no match.
Find text files
Search recursively below the current folder.
Ubuntu Bash
find . -name"*.txt"
✓ Expected: Matching relative paths.
Check: Matching relative paths.
Change user execute permission
Adds execute permission for the owner; does not turn a text file into a program.
Ubuntu Bash
chmod u+x test.txt
✓ Expected: Normally silent. Verify with ls -l or stat; a private directory should be 700 and a private credential file 600 where specified.
Check: ls -l shows x in the owner permission field.
Delete a practice file
-i asks before deleting. Deletion in Linux is normally not sent to the Recycle Bin.
Ubuntu Bash
rm -i notes.txt
✓ Expected: Answer y only if notes.txt is your disposable copy.
Check: Answer y only if notes.txt is your disposable copy.
Remove an empty directory
Fails if the directory contains files.
Ubuntu Bash
rmdir Documents
✓ Expected: Documents disappears if empty.
Check: Documents disappears if empty.
Ubuntu Bash
03 · Python, VS Code & execution
Check system Python
Print the installed Python 3 version.
Ubuntu Bash
python3--version
✓ Expected: The installed version is printed. For this toolkit InfluxDB must be 2.x; version numbers otherwise depend on installation.
Check: Python 3.x.
Activate the lab environment
Loads the packaged virtual environment and fakepi support for this terminal. Requires completed setup.
Ubuntu Bash
source ~/psut-wsl/activate.sh
✓ Expected: The toolkit virtual environment is selected in this terminal, usually with (.venv) in the prompt. Verify which python points into ~/psut-wsl/.venv.
Check: Prompt shows (.venv); which python points inside the toolkit.
Find the active interpreter
Check which executable will run when you type python.
Ubuntu Bash
which python
✓ Expected: The interpreter path ends in /psut-wsl/.venv/bin/python when the toolkit is active.
Check: With activation, path includes psut-wsl/.venv/bin/python.
List Python packages
Uses pip belonging to the active interpreter.
Ubuntu Bash
python-mpip list
✓ Expected: Installed package names and versions.
Check: Installed package names and versions.
Inspect a package
Check whether gpiozero is installed in the selected environment.
Ubuntu Bash
python-mpip show gpiozero
✓ Expected: Package details including Location.
Check: Package details including Location.
Go to a real lab
Navigate to the supplied GPIO Zero LED example.
Ubuntu Bash
cd ~/psut-wsl/labs/python/lab29
✓ Expected: Normally no output. pwd should show the requested directory. A missing path produces an error; do not continue until corrected.
Check: ls shows blink_gpiozero.py.
Run a lab program
After activating and entering Lab 29, execute the supplied program. It blinks in the background and waits in pause().
Ubuntu Bash
python blink_gpiozero.py
✓ Expected: The fake GPIO17 output alternates HIGH/LOW every 0.5 seconds. Press Ctrl+C to stop.
Check: Foreground remains running; fake GPIO state changes may be logged. Stop with Ctrl+C.
Run one Python expression
-c runs a short Python statement directly from Bash; no file required.
Ubuntu Bash
python-c"print(2 + 3)"
✓ Expected: 5 is printed.
Check: 5
Open interactive Python
Enter the >>> prompt after activation. Type print(2 + 3), then exit() to return to Bash.
Ubuntu Bash
python
✓ Expected: Python starts and shows the >>> prompt. Use exit() to return to Bash.
Check: >>> appears; shell commands do not belong here.
Leave the virtual environment
Returns the shell to its previous Python environment.
Ubuntu Bash
deactivate
✓ Expected: (.venv) disappears.
Check: (.venv) disappears.
Open the toolkit in VS Code
From Ubuntu, open the whole workspace in the WSL remote window. Requires VS Code and WSL extension.
Ubuntu Bash
cd ~/psut-wsl
code .
✓ Expected: VS Code opens the current directory; confirm the WSL remote indicator for Linux projects.Expected result for each action (2)
cd ~/psut-wslNormally no output. pwd should show the requested directory. A missing path produces an error; do not continue until corrected.
code .VS Code opens the current directory; confirm the WSL remote indicator for Linux projects.
Check: VS Code opens the toolkit; status bar indicates WSL.
Install all toolkit services
Run once after copying the toolkit. Installs base Python and optional services; requires internet and sudo.
Ubuntu Bash
bash ~/psut-wsl/setup_wsl.sh --all
✓ Expected: The installer completes and returns to the prompt. Verify the selected services and run the toolkit self-test; package logs may vary.
Check: Installer completes; run self-test next. See Setup for details.
Run the toolkit self-test
Checks core setup and reports failures.
Ubuntu Bash
bash ~/psut-wsl/tools/selftest.sh
✓ Expected: The toolkit reports checks for the installed components. Review any FAIL or unavailable optional service before continuing.
Check: Inspect the result and fix any failed checks.
Ubuntu Bash
04 · Linux system, processes & services
Show your Linux username
Identify the current Linux account.
Ubuntu Bash
whoami
✓ Expected: Your Linux username.
Check: Your Linux username.
Identify Ubuntu
Read distribution information.
Ubuntu Bash
cat /etc/os-release
✓ Expected: Ubuntu and version ID, e.g. 24.04.
Check: Ubuntu and version ID, e.g. 24.04.
Inspect the kernel
Show kernel and architecture information.
Ubuntu Bash
uname -a
✓ Expected: Linux kernel details; WSL kernel is not a Pi kernel.
Check: Linux kernel details; WSL kernel is not a Pi kernel.
Check free disk space
Report filesystem capacity in readable units.
Ubuntu Bash
df -h
✓ Expected: Size, Used and Avail columns.
Check: Size, Used and Avail columns.
Check memory
Report memory and swap usage.
Ubuntu Bash
free -h
✓ Expected: Mem and Swap rows.
Check: Mem and Swap rows.
List running processes
Inspect process IDs and command lines.
Ubuntu Bash
ps aux
✓ Expected: A process table.
Check: A process table.
Watch live processes
Interactive CPU and memory monitor. Press q to leave.
Ubuntu Bash
top
✓ Expected: Continuously updating process list.
Check: Continuously updating process list.
Review recent Bash commands
Shows commands in this shell history; do not share secrets from it.
Ubuntu Bash
history
✓ Expected: Numbered command history.
Check: Numbered command history.
Clear terminal display
Clears the screen, not your files.
Ubuntu Bash
clear
✓ Expected: A clean terminal.
Check: A clean terminal.
Refresh Ubuntu package index
Downloads package metadata. It does not upgrade installed programs.
Ubuntu Bash
sudoapt update
✓ Expected: Repository metadata is refreshed and the prompt returns without repository errors.
Check: Package lists read successfully.
Install a package
Installs the tree utility using Ubuntu package manager.
Ubuntu Bash
sudoapt install -y tree
✓ Expected: Packages are installed or already up to date; the prompt returns. Verify executable availability before using them.
Check: tree --version works.
Start the MQTT service
Requires Mosquitto installed and systemd enabled in WSL.
Ubuntu Bash
sudosystemctl start mosquitto
✓ Expected: Normally no output on success. Run systemctl is-active for the named service and confirm active; inspect logs if it fails.
Check: systemctl is-active mosquitto prints active.
Inspect a service
Show service state and recent log entries.
Ubuntu Bash
systemctl status mosquitto--no-pager
✓ Expected: The service status and recent log lines appear. Look for Active: active (running) for a running service.
Check: Active: active (running), if healthy.
Restart Mosquitto
Interrupts connections briefly; use after config changes.
Ubuntu Bash
sudosystemctl restart mosquitto
✓ Expected: Normally no output on success. Run systemctl is-active for the named service and confirm active; inspect logs if it fails.
Check: Service active again; publisher may need reconnect.
Read service logs
Inspect the last 30 log lines for startup or listener errors.
Ubuntu Bash
sudo journalctl -umosquitto-n30--no-pager
✓ Expected: Recent service log entries appear. Check errors and timestamps; redact credentials before sharing.
Check: Recent service log entries.
List listening TCP ports
-l listening, -t TCP, -n numeric addresses.
Ubuntu Bash
ss-ltn
✓ Expected: Socket table appears; check the required protocol, port and connection state. Empty results may be normal without active connections.
Check: Look for 1884, 1880, 8086 or 3000 when services are running.
Show Linux IP addresses
Lists assigned Linux addresses; WSL IP may change.
Ubuntu Bash
hostname -I
✓ Expected: IP addresses assigned to the Linux environment are printed; actual addresses vary.
Check: One or more addresses.
Check InfluxDB health
Queries local InfluxDB health; requires the service running.
Ubuntu Bash
curl-fsS http://127.0.0.1:8086/health
✓ Expected: InfluxDB health JSON includes status pass when the service is healthy; this does not verify bucket permissions or stored data.
Check: A JSON health response; failure means inspect service first.
Subscribe to a local test topic
Run in Terminal A. Keep it open; requires local Mosquitto configured by Setup.
✓ Expected: Usually silent on success. Confirm the exact topic and payload in a separate subscriber; this is not proof of database storage.
Check: Terminal A prints linux-practice/test hello.
Windows PowerShell
05 · WSL management from Windows
List installed distributions
Show distribution names, running state and WSL version. Use the exact name in other commands.
Windows PowerShell
wsl--list--verbose
✓ Expected: A table of installed distributions, STATE and VERSION appears. Verify the intended distribution is listed with VERSION 2.
Check: Ubuntu-24.04 should appear with VERSION 2 after installation.
List available distributions
Show installable Linux distributions. Requires internet.
Windows PowerShell
wsl--list--online
✓ Expected: List includes distribution names.
Check: List includes distribution names.
Install Ubuntu 24.04
Use Administrator PowerShell if Ubuntu is not installed. Restart if requested and create the Linux user.
Windows PowerShell
wsl--install-dUbuntu-24.04
✓ Expected: Installation completes or Windows requests a restart. On first launch create your Linux username and password; the prompt resembles username@PC:~$. Verify the distribution with wsl -l -v (VERSION 2). WSL is a Linux environment, not a physical Raspberry Pi.
Check: wsl -l -v lists Ubuntu-24.04.
Open Ubuntu
Start the named distribution even if Kali or another Ubuntu is the default.
Windows PowerShell
wsl-dUbuntu-24.04
✓ Expected: The selected Linux shell opens; on first launch complete account creation. The prompt ends in $. No physical board is connected by this command.
Check: Linux Bash prompt appears.
Set default distribution
Makes Ubuntu-24.04 the default when running wsl. Does not delete other distributions.
Windows PowerShell
wsl--set-defaultUbuntu-24.04
✓ Expected: An asterisk marks Ubuntu-24.04 in wsl -l -v.
Check: An asterisk marks Ubuntu-24.04 in wsl -l -v.
Choose WSL 2 for future installs
Changes the default for new distributions, not existing installations.
Windows PowerShell
wsl--set-default-version2
✓ Expected: Command completes successfully.
Check: Command completes successfully.
Convert an existing distribution
Only needed if the distribution is version 1. Back up first and stop active programs.
Windows PowerShell
wsl--set-versionUbuntu-24.042
✓ Expected: wsl -l -v shows VERSION 2.
Check: wsl -l -v shows VERSION 2.
Check WSL settings
Display default distribution and WSL configuration information.
✓ Expected: Backup TAR file appears in your Windows user folder.
Check: Backup TAR file appears in your Windows user folder.
Ubuntu Bash
06 · Essential shell skills
Return from Ubuntu to Windows
If launched from PowerShell, exits the current Linux shell. Does not necessarily stop all WSL processes.
Ubuntu Bash
exit
✓ Expected: PowerShell prompt returns.
Check: PowerShell prompt returns.
Run a Windows WSL command from Bash
Use wsl.exe inside Ubuntu to invoke the Windows executable. Normally manage WSL in PowerShell instead.
Ubuntu Bash
wsl.exe--list--verbose
✓ Expected: A table of installed distributions, STATE and VERSION appears. Verify the intended distribution is listed with VERSION 2.
Check: Windows list of distributions.
Read a command manual
Open ls manual; press q to leave.
Ubuntu Bash
man ls
✓ Expected: Manual page appears if installed.
Check: Manual page appears if installed.
Read command options
Show quick usage without opening a manual.
Ubuntu Bash
ls--help
✓ Expected: The requested files/directories are listed; compare names and permissions with the guide. An empty directory can produce no output.
Check: ls options and syntax.
Run two commands conditionally
&& executes ls only if pwd succeeds.
Ubuntu Bash
pwd&&ls
✓ Expected: An absolute Linux path appears, matching the directory selected in the preceding step.
Check: Current path followed by entries.
Pipe output between commands
| sends output of ls to head; prints at most five lines.
Ubuntu Bash
ls-la| head -n5
✓ Expected: The requested files/directories are listed; compare names and permissions with the guide. An empty directory can produce no output.
Check: First five listing lines.
Destructive WSL commands — read before using
Warning: unregistering a distribution permanently deletes its Linux filesystem, installed programs and data. To remove a distribution deliberately, first export a backup, verify the exact name with wsl -l -v, and consult the official instructions for wsl --unregister. No executable deletion command is supplied here. Shutdown and terminate do not uninstall a distribution.