Chapter 6. Parents, Children, and Environments
The purpose of the shell—to run commands—is so fundamental to
Linux that you might think the shell is built into Linux in some
special way. It is not. A shell is just an ordinary program like ls
or cat
. It is programmed to repeat the following steps over and over
and over and over…
-
Print a prompt.
-
Read a command from stdin.
-
Evaluate and run the command.
Linux does a great job of hiding the fact that a shell is an ordinary program. When you log in, Linux automatically runs an instance of the shell for you, known as your login shell. It launches so seamlessly that it appears to be Linux, when really it’s just a program launched on your behalf to interact with Linux.
Where Is Your Login Shell?
If you log in at a nongraphical terminal, say, using an SSH client program, the login shell is the initial shell you interact with. It prints the first prompt and awaits your command.
Alternatively, if you’re at the computer’s console with a graphical display, your login shell runs behind the scenes. It launches a desktop environment such as GNOME, Unity, Cinnamon, or KDE Plasma. Then you can open terminal windows to run additional interactive shells.
The more you understand about the shell, the more effectively you can work with Linux and the fewer superstitions you’ll develop about its inner workings. This chapter explores the following mysteries of shells more deeply than Chapter 2 did:
-
Where shell programs are located
-
How different ...
Get Efficient Linux at the Command Line now with the O’Reilly learning platform.
O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.