Chapter 2
The Command Line, Enough of It
Open a Terminal
Every program you have written so far ran because you pressed a button. Somebody else decided where it ran and what it could see. From here on you decide, and the way you tell a computer to run something is by typing its name.
A
The one below this lesson
There is a terminal underneath this text. It is a real one, running on a real machine, and everything you type into it actually happens. It is not a simulation of a shell, which matters, because a simulation would let you get away with things a real shell will not.
Start by asking it where you are:
pwd
It answers /workspace.
That is your working directory: the folder the shell is currently standing in. Every command you type is interpreted from there. pwd is short for “print working directory”, and it is the most useful command there is when something goes wrong, because “the computer cannot find my file” and “I am not where I think I am” are the same problem far more often than beginners expect.
Type it whenever you feel lost. It costs nothing and it changes nothing.
The prompt is waiting, not stuck
Before the place where you type, the shell prints a prompt. It might be a $, or your username, or the name of the directory you are in. Its only job is to tell you the shell has finished the last thing and is ready for the next.
A prompt sitting there doing nothing is not a frozen computer. It is a computer waiting for you.
The same thing on your own machine
This chapter rehearses here, where a mistake costs nothing. But the terminal you actually want is the one on your own computer, so open that too and keep it beside you.
Press Cmd + Space, type Terminal, and press Enter.
You can also find it in Applications → Utilities → Terminal.
Press the Start button, type PowerShell, and press Enter.
Windows also has an older program called Command Prompt (cmd). Use PowerShell for this course, because its Windows instructions use PowerShell syntax. Command Prompt is a different shell with different commands.
Press Ctrl + Alt + T. On most desktop environments that opens your terminal.
If it does not, search your applications for Terminal, Konsole, or GNOME Terminal, depending on which desktop you are running.
If none of that works, or you want the other ways in, Computer Fundamentals covers opening a terminal on all three systems:
Type pwd in it. You will get something different from /workspace, probably your home directory, something like /Users/you or C:\Users\you. That is the shell telling you where it starts.
You open a terminal, type pwd, and get /workspace. What does that tell you?
Next: what is actually in the directory you are standing in.