Chapter 2. Introducing the Shell
So, you can run commands at a prompt. But what is that prompt? Where does it come from, how are your commands run, and why does it matter?
That little prompt is produced by a program called a shell. Itâs a
user interface that sits between you and the Linux operating system.
Linux supplies several shells, and the most common (and the standard
for this book) is called
bash. (See AppendixÂ B for notes about
bash and other shells do much more than simply run commands. For
example, when a command includes a wildcard (
*) to refer to multiple
files at once:
$ ls *.py data.py main.py user_interface.py
the wildcard is handled entirely by the shell, not by the program
ls. The shell evaluates the expression
*.py and invisibly
replaces it with a list of matching filenames before
ls runs. In
ls never sees the wildcard. From the perspective of
ls, you typed the following command:
$ ls data.py main.py user_interface.py
The shell also handles the pipes you saw in ChapterÂ 1. It redirects stdin and stdout transparently so the programs involved have no idea they are communicating with each other.
Every time a command runs, some steps are the responsibility of the
invoked program, such as
ls, and some are the responsibility of the
shell. Expert users understand which is which. Thatâs one reason they
can create long, complex commands off the top of their head and run
them successfully. They already know what the command will do before ...