permacomputing

Source repository for the main permacomputing wiki site
git clone http://git.permacomputing.net/repos/permacomputing.git # read-only access
Log | Files | Refs

commit 840260baca4390bd36991c5b7b168e6b97454e2f
parent 5ed4dc3fe2fa155530ce6fac93acf7728f24cf41
Author: smeeb <smeeb@web>
Date:   Thu, 26 Nov 2026 16:50:06 +0100


Diffstat:
Mrecomposing_ewaste.mdwn | 322++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++-
1 file changed, 321 insertions(+), 1 deletion(-)

diff --git a/recomposing_ewaste.mdwn b/recomposing_ewaste.mdwn @@ -177,8 +177,328 @@ Note: this tutorial is based on the first few patches from the [GOTO10 canvas Pd * Groups of 2, installed phones available. Crash course command line so they know how to start <code>pd</code> and the different parts and start to play with the synth (Boris). 120 min (including tea break) +# Terminal crash course + +Open the Terminal app. You'll see something like this: + +``` +user@laptop:~$ +``` + +This is the prompt. It tells us who you are (`user`), which computer you are on (`laptop`) and the folder you're in (`~` is your home folder). + +Before we really start you should know this: + +- Copy and pasting in the terminal are Ctrl+Shift+C and Ctrl+Shift+V. +- Ctrl+C does not copy. It stops whatever is running. +- When you type a password, nothing appears on screen. That's normal, keep typing! +##### Where am I? + +Try out the following commands one by one. + +```bash +pwd +ls +cd Downloads +pwd +cd .. +cd ~ +``` + +- `pwd` (_print working directory_): shows the folder you are currently in +- `ls` (_list_): lists what's in the current folder. +- `cd` (_change directory_): moves you to another folder. `cd Downloads` moves you into Downloads. +- `cd ..`: goes back (up) one folder +- `cd ~`: takes you back home from anywhere. + +Many of these commands print nothing when they work. No message means _usually_ it went fine. +##### Navigating the filesystem + +All files and folders on the computer are inside one big folder called `/`. Let's go there and look around: + +```bash +cd / +ls +ls /home +ls /etc +ls /usr/bin +cd ~ +``` + +Some folders worth knowing: + +- `/home`: the home folder of the user. Yours is `/home/user` and is also called `~` +- `/etc`: settings for the whole system +- `/usr/bin`: programs. `bin` is short for binaries, another word for programs. Every command you type is a program in a folder like this. +- `/tmp`: temporary files. This folder gets emptied when the computer restarts + +There are two ways to write where something is: + +- A full path starts with `/` and works from anywhere: `/home/user/Downloads`. +- A relative path starts from where you are now (if I'm in `/home/user`): `Downloads`. + +##### Creating folders and a files + +```bash +mkdir practice +cd practice +nano hello.txt +``` + +- `mkdir` (_make directory_): makes a folder. +- `nano`: is a simple text editor. + +Type a sentence in nano. Save with Ctrl+O and press Enter, then quit with Ctrl+X. Now check that the file is there and read it: + +```bash +ls +cat hello.txt +``` + +- `cat` (_concatenate_): prints the contents of a file + +##### Copy, rename and delete + +```bash +cp hello.txt copy.txt +mv copy.txt renamed.txt +ls +rm renamed.txt +ls +``` + +- `cp` (_copy_): copies a file. +- `mv` (_move_): moves a file. Moving it to a new name in the same folder renames it +- `rm` (_remove_): deletes a file. There is no trash bin in the terminal. When you delete something its really gone + +Folders work a bit differently: + +```bash +mkdir stuff +rm -r stuff +``` + +- `rm -r` (_recursive_): deletes a folder and everything inside it + +Spaces in file names need quotes because the terminal uses spaces to separate words. Avoid spaces in file names and use `-` or `_` instead, for example `my-manifest.txt` + +```bash +touch "my manifest.txt" +ls +rm "my manifest.txt" +``` + +- `touch`: makes an empty file. +##### Many files at once + +```bash +touch a.txt b.txt c.txt +ls *.txt +ls *.pd +rm a.txt b.txt c.txt +``` + +`*` means "anything". `ls *.txt` shows every file that ends in `.txt`. Be careful with it: `rm *` deletes everything in the folder. +##### Shortcuts! + +- `Tab`: completes names. Type `cat hel` and press Tab. +- `Tab` twice: shows all possibilities. Type `ls /usr/` and press Tab twice +- `↑` (_arrow key up_): brings back your previous commands. + +```bash +history +clear +``` + +- `history` shows everything we've typed so far. +- `clear` empties the screen. Ctrl+L does the same. + +##### Changing what a command does + +```bash +ls -l +ls -a ~ +ls -la ~ +ls --help +``` + +The command is what to do, the options (usually starting with `-`) modify how to do it, and the rest says what to do it to. Options are often the first letter of a word: + +- `ls -l` (_long_): shows a long list with more details. +- `ls -a ~` (_all_): shows all files in your home folder, including hidden ones. Hidden files start with a dot. +- `ls -la ~`: combines both options +- `ls --help`: shows all the options of the command. + +##### Read the (friendly) manual! + +Every command has a manual. Let's look up what `yes` does: + +```bash +man yes +``` + +- `man` (_manual_): opens the manual of a command. Scroll with the arrow keys, search with `/` followed by a word, and press `q` to quit. `--help` gives a short summary, and `man` gives the full manual. + +The manual says `yes` repeats a text until it's stopped. That's where the name comes from: without any text, it prints "y" forever. + +```bash +yes hello +``` + +This prints "hello" forever. Press Ctrl+C to stop it. + +##### Who am I? + +```bash +whoami +hostname +date +uptime +cat /etc/os-release +free -h +df -h +``` + +- `whoami` (_who am I_): shows your username. +- `hostname`: shows the name of your computer +- `date`: shows the date and time. +- `uptime`: shows how long the computer has been on +- `cat /etc/os-release`: shows which operating system you are running. +- `free -h`: shows how much memory is used and free. +- `df -h` (_disk free_): shows how much space is left on your disks + +The `-h` (_human readable_) option shows sizes in MB and GB instead of bytes. + +##### Installing software + +```bash +sudo apt update +sudo apt install cowsay fortune-mod +``` + +- `sudo` (_superuser do_): means you do this as the administrator. The administrator is also called root or superuser. It asks for your password. +- `apt` (_Advanced Package Tool_): installs software on Debian. +- `apt update`: downloads the latest list of available software. It's a good idea to run it before installing + +Try out what you just installed: + +```bash +cowsay hello +fortune +``` + +To find out where a program lives: + +```bash +which ls +which cowsay +``` + +- `which`: shows the folder a program is installed in +##### Connecting commands + +```bash +echo "hello from the terminal" +echo "hello from the terminal" | cowsay +fortune | cowsay +``` + +- `echo`: repeats what you give it, like an echo. +- `|` (the pipe): sends the output of one command into the next one + +The pipe also lets you write text into a file with `tee`: + +```bash +echo "first line" | tee notes.txt +echo "second line" | tee -a notes.txt +cat notes.txt +echo "third line" | tee notes.txt +cat notes.txt +``` + +- `tee`: writes what it receives to a file and shows it on screen. +- `tee -a` (_append_): adds to the end of the file +- `tee` without `-a` overwrites the file + +##### Logging in to the phone + +Connect the phone to your computer with the micro USB cable. The phone always has the address `172.16.42.1` on the cable. First check that it answers: + +```bash +ping 172.16.42.1 +``` + +- `ping`: sends a message and waits for a reply. When you see replies coming in, stop it with Ctrl+C + +Now log in to the phone: + +```bash +ssh user@172.16.42.1 +``` + +- `ssh` (_secure shell_): lets you use the terminal of another computer. The shell is the program that reads and runs the commands you type. `user@172.16.42.1` means: log in as `user` on the computer at this address. +- The password is `147147`. +- The first time, it asks whether you trust this device. Type `yes` and press Enter. + +Your prompt changes to: + +``` +unbrick01:~$ +``` + +From now on, every command runs on the phone (as you are now logged in to the phone). Always check the prompt to see where you are. Everything you learned works here too: + +```bash +pwd +ls +hostname +free -h +``` + +##### Start unbrick01 + +to run `unbrick01` we need three programs running at the same time, each in its own terminal window. Open a new window with Ctrl+Shift+N, log in to the phone again with `ssh user@172.16.42.1`, and repeat for each program. Start them in this order. + +**The audio server** + +```bash +JACK_NO_AUDIO_RESERVATION=1 /usr/bin/jackd -d alsa -S -p 128 +``` + +`jackd` is the JACK audio server: it gives programs like Pd access to the sound card + +- `JACK_NO_AUDIO_RESERVATION=1` ?? +- `-d alsa` (_driver_) talks to the sound card through ALSA, the sound system of Linux. +- `-S` uses 16-bit sound +- `-p 128` (_period_) processes sound in small parts of 128 samples. Smaller parts mean less delay between touching and hearing. + +**The touch script** + +```bash +cd ~/unbrick01/pd/startup +python3 touch2pd.py +``` + +- `touch2pd.py` (_touch to Pd_): a Python script that reads the touchscreen and the buttons and sends that information to Pd. `python3` is the program that runs Python scripts. + +**The Pd patch** + +```bash +cd ~/unbrick01/pd/unstable +pd -nogui -stderr -jack chkahichdahk.pd +``` + +`pd` is the program to load Pure Data patches (`.pd` files) + +- `-nogui`: no graphical user interface +- `-stderr` (standard error): where programs send their messages +- `-jack`: send the sound through JACK +- `chkahichdahk.pd`: the name of the Pd patch to open + +Now plug in your headphones, touch the screen and press the buttons. You should hear sound! + +Keep the tabs open, when you close a tab, the program in it stops too. -<code>TODO CLI tutorial + 3 terminals trick</code> Day 2. Saturday 28th of November ================================