Section 0.2: The Shell
The shell is the program that reads what you type and decides what runs. Section 1 already used a handful of commands to make files, folders and processes. This section turns to the program that read those commands, how it reads a line and what every command inherits from it, and then to the point where you stop running commands one at a time and start composing them.
Two invisible inputs decide most of what happens. The first is the environment a command inherits, which is what settles the question of which program a bare name actually runs. The second is the set of three byte channels every command is born with, one for results and one for errors and one for input, and once you can see those as separate things rather than as text on a screen you can send each one wherever you want, and wire the output of one program straight into the next with no file in between. The section closes on the network, sending messages to your own machine and to another one, then watching a request and its response cross a server you start yourself.
Lessons
- The Shell, Your First Commands, and the Environment - what the shell is, how a command is read, creating and destroying files by hand, and what a process inherits, including how
PATHdecides which program a bare name actually runs. - Redirection and Pipes - Aiming and Composing Streams - the three channels every command has, sending each one where you want it, and wiring commands together into pipelines.
- The Network Surface - Hosts, Ports, and Local Servers - addressing another machine, and the request and response pattern behind a local server.
By the end you will be able to:
- Read a command left to right and name which part is the verb, which the target, and which the modifier.
- Explain which program a bare command name will run, and why, and set a value that outlives the session.
- Predict which stream a given command's output lands on before running it.
- Redirect results and errors into one file, in the correct order, and say why the wrong order loses the errors.
- Compose three or more commands into one pipeline with no intermediate files.
- Start a local server and describe each step of a request that reaches it.