0%

Chapter 6

The Command Line

Open a Terminal and Ask Where You Are

Your computer already has a . You do not have to install one, and the one it gives you is the right one to learn on.

Which application it is, and which answers inside it, depends on the machine in front of you. The ideas underneath do not depend on any of that, which is why this chapter teaches them once.

Open it

Try Ctrl + Alt + T first, which many desktops bind to a terminal. If nothing opens, search your applications menu for terminal. The usual names are Terminal, GNOME Terminal, Konsole, and Xfce Terminal.

Most distributions start Bash, though yours may be set up differently. This chapter’s commands behave the same either way.

The window that opens shows a prompt, which is the shell saying it is ready for the next thing. Prompts are configurable, so yours will not match anyone else’s exactly:

sam@computer:~$

The $ at the end is the common prompt symbol. The username, machine name, and location in front of it are decoration your shell configuration chose.

Whatever it looks like, the prompt is output, not something you type. Documentation that shows a prompt in front of a command is giving you context; copy only what comes after it.

Ask one harmless question

The first useful command reports the working directory, which is the folder the shell is standing in and the place every you type gets resolved from. It creates nothing, moves nothing, and removes nothing, so it is always safe to run.

Click into the terminal beside this lesson and run it:

pwd

pwd is short for “print working directory”. Unix command names are terse by tradition, which is quick to type and worth translating in your head the first few times.

In a fresh workspace the answer is /workspace. Run it a second time and you get the same answer, because asking a question changed nothing. That is the habit this whole chapter is built on: look before you touch.

Two terminals, two machines

The terminal beside this lesson is not the terminal on your own computer. It is a disposable hosted sandbox holding this chapter’s practice files, and it starts at /workspace.

Run the same command in your own terminal and you will get something else: a Windows path such as C:\Users\Sam, or /Users/sam on a Mac, or /home/sam on . Do not try to make the two match, and never copy a sample username. They are two different computers with two different filesystems.

Both answers are correct, and the difference is the point. The graded work happens in the sandbox, where the starting conditions are known and nothing you do can reach anything you own.

You open the lesson terminal, and the first command you run reports /workspace. What have you learned?

You have a terminal open, you can tell the prompt from the answer, and you have asked the shell one question that changed nothing. Next, the three questions worth asking in order: where am I, what is here, and how do I get somewhere else.