What is the Terminal?

When developers talk about the "terminal", there are several different terms they may use: command line, or console, or terminal, or shell. Historically, all these terms have distinct meanings and separate origins. But the beautiful thing about language is it evolves!

Today, the two main concepts to keep in mind are the terminal and the shell.

The terminal is a program that lets you type commands to your computer and see the results. You could think of it as an advanced window into a computer's data. For Windows, the default terminal program is the Windows Terminal (as of 2023). On Mac OS, the default is Terminal. And on Linux, the default...well, it depends on the distribution of Linux you're using.

By itself, the terminal doesn't do much. The primary form of interacting with computer's data is with a program that runs "inside" the terminal, most often a shell program. When you open a terminal program, it will open a shell and wait for you to start giving commands. You can then type commands and submit them with the "Enter" or "Return" key. A submitted command is also called a command line. The shell will then try to execute your command line, display the results, and then wait for more commands.

Terminal

How to Read the Examples

As this is an introduction to the terminal, there will be some examples of terminal commands used in this book. A common convention used in other texts looks like this:

$ echo "Hello"
Hello

When you see a block of text that looks like this, it should be read as code. Most of the code in this book will be in the language of the shell, and any exceptions will be noted.

The first line starts with a dollar sign, followed by the command. The dollar sign here is also called the prompt. When you see such a line, you can run the same command by typing in everything on the line after the dollar sign. In this case, echo "Hello". In some cases, such as Windows command lines, the default symbol is a right angle bracket instead:

> echo "Hello"
Hello

The second line is the output of the command, which usually includes the results of the command, and extra information that may be useful or helpful. That could be more context about the command's operation, or information about anything that went wrong and resulted in an error. We also say that output is printed to the screen, or console, or terminal - or to files!

Inline Code References

There may also be times, such as two paragraphs before this one, where something is formatted a little different from the other text: it will look like this. This formatting should also be read as a reference to something in code, but being used in the middle of...well, some non-code text, like this paragraph!

A code block may also include some lines that have a # at the beginning or in the middle:

$ ps # show the current processes on the system
  PID TTY          TIME CMD
   98 pts/0    00:00:00 bash
  192 pts/0    00:00:00 ps

A #, also known as the pound sign, the hash mark, or (my favorite) the octothorpe, means that anything that comes after it on the same line is a comment. Comments are ignored when your computer executes your code, so you can use them to explain a section of code, document a piece of code, or otherwise communicate to other developers.

Shell Scripts

Some code blocks will have a specific line at the top that looks a bit like a comment:

#!/usr/bin/env bash
some_command

What this exactly does is explained later, but for now, you can interpret this as meaning the code block is a standalone shell script, or a file of shell commands.

For now, you should just keep one thing in mind about shell scripts: they will only have commands and comments written inside of them, and there won't be any output shown in these code blocks.

Choices to Consider

This section is optional, and many developers have perfectly satisfying and successful careers without exploring the choices here. But it can be fun, and I think it's worth a quick mention.

As previously mentioned, we have two main programs when we work in the terminal: the terminal itself, and the shell program running in the terminal. In 2024, the options available for both of those programs are vast and numerous, with a whole assortment of trade-offs to evaluate and ponder!