💾 Archived View for idiomdrottning.org › the-terminal-and-the-shell captured on 2024-03-21 at 16:25:33. Gemini links have been rewritten to link to archived content
⬅️ Previous capture (2023-01-29)
-=-=-=-=-=-=-
These days, many computers and phones have access to an old-school Unix-style command line. Sometimes through an app that for historical reasons is called the “terminal”.
To have access to Unix-style computers is such a luxury and I want to talk a little about the weird things you can do that can save you time or, if you’re lucky, waste your time on fun stuff. Be careful in the terminal. It’s an app a lot of people are afraid of, kind of hesitant to use, and that’s with good reason. It’s one of the few things on your computer that can really mess it up, because it’s so powerful. But it’s fun to be curious!
You might recall that the word “terminal” means “related to an endpoint”, right? It’s French, and ultimately from the Latin “terminus”, which means “endpoint”. Kind of a grim word... Yet we see it all the time, in airports, rail stations and electronics. In the olden days, computers were these big hulking machines that filled up a room. People didn’t have computers in their desks, kitchens and pockets the way they do know. Not even in the office. So they figured out a smart thing. On the desks, they put a screen and a keyboard and connected them with long wires (or over the telephone net, which was wired back then) to the big computer. These were called “terminals”: they were the endpoint of the computer. Sometimes they were called “dumb terminals” because they weren’t powerful computers themselves, just a keyboard and a screen and a little network glue code to get it to work.
Unix is so old, it was created for these huge computers, and people used “terminals” to connect to them. When it moved to the desktop, people started using “terminal emulators” — an “emulator” is a program that tries to emulate or be similar to another program or machine — instead, and after years of use, the word “emulators” fell away and now the programs are sometimes themselves called “The Terminal”. Just like Frankenstein’s monster is himself often called “Frankenstein”, taking on his creator’s name.
Unix started as a parody of another big system, Multics. The name is supposed to sound like “Eunuchs”. I guess I just don’t like jokes. One of the best versions of Unix, or at least one of my favorites, is GNU, which also is a parody of Unix. The name stands for “GNU’s Not Unix”. They looked through the dictionary for all the words that ended with “INU” so they could call it “[Something] Is Not Unix” but they didn’t find anything; they contracted the copula (the “is”) and ended up with GNU, which they called “The funniest word in the English language”. To me “XINU” would’ve been an obvious candidate since that would be Unix backwards. But that’s that.
So what is it we see when we open the terminal? The terminal can run any program, just think of it as a computer screen that’s trying to be old school. The most common program to run there is the “shell”. So what’s that?
Complex systems are often layered like onions and in the case of most modern Unix systems, they use the analogy of a nut. The middle part, the “kernel”, is close to the metal and the part you interact with is called the “shell”.
When you start the shell, you get a “prompt”, which just means a place to write. In the classic Bourne shell, the default prompt is just a dollar sign.
$
The first word you write there is the name of a program, the following words are what you want that program to know before it starts. Sounds weird? Let’s look at an example.
$ echo Hello darkness my old friend
This is me calling the program echo and telling it five things: Hello, darkness, my, old and friend. The first word I wrote, echo, has to be a command that the shell knows about. The words after that, the shell don’t have to care about, it just finds echo and passes the rest to it. It’s a simple fellow, echo, it just repeats back whatever it’s told.
$ echo Hello darkness my old friend Hello darkness my old friend
The first line, the line with the $, is what I typed. The second line is what echo printed back at me. (I didn’t type the $, I just typed what followed it. Think of the $ as the shell’s question mark, its prompt to me to write something.)
Here is an example of the shell not finding a command.
$ Can I just type anything sh: 1: Can: not found
The shell doesn’t care about I, just, type or anything, all it cares about is the first word, Can, which it believes is a program that it is expected to know about. I guess it is just a fool for thinking so.
After the classic Bourne shell, the two most commonly used shells today are bash and zsh. This is how bash looks:
sandra@ellen:~/skami/dwm-6.0$ Can I just type anything bash: Can: command not found
bash has a longer default prompt. It’s the familiar dollar sign $ from the Bourne shell (the name bash is an abbreviation for Bourne Again shell), preceded by my name, my computer’s name, and the name of the place on that computer where it thinks I am working right now (the “current directory”).
I am sandra, my computer is called ellen (named after a character in an old Maria Gripe novel) and \~/skami/dwm-6.0 is a folder on my computer. For some reason, bash likes to tell me all that stuff everytime it asks me something. I guess it wants to present itself as a familiar pal.
This is how zsh looks:
ellen% Can I just type anything zsh: command not found: Can
It just tells me my computer’s name. I don’t know why. It’s easy to change how the prompt look on both bash and zsh, so don’t base your choice of shell on that.