Hello, and welcome to the first episode of the Software Carpentry lecture on the Unix shell. In this episode, we'll explain what a shell is, and why you might want to work as if the year was 1975.
At a high level, computers really do four things.
They run programs.
They store data.
They communicate with each other.
And they interact with us.
They can do the last of these in many different ways.
For example, they can use telepathy, i.e., direct brain-computer links. This technology is still in its infancy, but I for one look forward to being assimilated as it matures.
Another way to interact with computers is to talk to them. No, to talk to them, not dock the pen. Um, as you can tell, this technology is also still somewhat immature.
What most of us use for interacting with computers is a WIMP interface: windows, icons, mice, and pointers. While these technologies didn't become widespread until the 1980s, their roots go back to Doug Engelbart's work in the 1960s, which you can see in what has been called "The Mother of All Demos".
Going back even further, the only way to interact with early computers was to rewire them.
But in between, from the 1950s to the 1980s and into the present day, people have used a technology that's based on the old-fashioned typewriter, and that technology is what we're going to explore in this lecture.
When I say "typewriter", what I actually mean is…
…a line printer connected to a keyboard, like the DECWriter LA-36 shown here.
These devices only allowed input and output of the letters, numbers, and punctuation found on a standard keyboard, so programming languages and interfaces had to be designed around that constraint.
Although if you were clever enough, you could find ways to do simple pictures using just those characters.
This kind of interface is called a CLUI, or command-line user interface, to distinguish it from the GUIs, or graphical user interfaces, that most of us are now used to.
Normally, a user starts a CLUI session by logging in with a user ID and password.
The user then types a command.
The computer executes the command and prints it output: in the case of older terminals, literally printing the output onto paper, a line at a time.
The user then types another command…
…which the computer executes, displaying output…
…and so on until the user logs off and takes his or her roll of paper away to study.
From this description, you'd think that the user was sending commands directly to the computer, and that the computer was sending output directly to the user.
In fact, there's a program in between called a command shell.
What the user types goes into the shell, which figures out what commands to run and orders the computer to execute them. The computer then sends the output of those programs back to the shell, which takes care of displaying things to the user.
A shell is just a program like any other; the only thing that's different about it is that its job is to run other programs, rather than to do calculations itself.
The most popular Unix shell is bash, the Bourne again shell. (It's called that because it's derived from a shell written by Stephen Bourne. This is what passes for wit among programmers.) Bash is the default shell on most modern implementations of Unix…
…and also comes with Cygwin, the Unix-on-Windows toolkit that we're using in this course.
Using it, or any other shell, feels a lot more like programming that like using windows and mice.
Commands are terse—often only a couple of characters long—and their names are often cryptic.
So why should you use it? There are two good reasons.
First, many tools only have command-line interfaces, or are easiest to use—particularly on remote machines—through the command line.
Second, the shell allows you to combine existing tools in powerful ways to create new tools of your own with little or no programming. As we'll see later in this lecture, this lets you do a lot of work with just a few keystrokes—once you have paid the up-front cost of learning how the shell works and what its basic commands are.
In the next episode, we'll take a look at how to find your way around files and directories using the shell.