Linux, terminal and Git

Stage 2 · Lesson 5 of 9

Redirection and the three streams

Shell basics

Every program has three streams, like three attached to it. (stdin) is what it reads. Standard output (stdout) is its normal results.

Standard error (stderr) is its warnings and error messages. Redirection sends these streams somewhere else. > writes output to a file and replaces what was there.

>> adds to the end of the file instead. < feeds a file in as input, and 2> sends errors to a file. 2>&1 sends errors to the same place as normal output, and /dev/null is a bin that throws output away.

Because the streams are separate, a command can show a warning on screen while its real results go to a file. Scripts, jobs and logs all rely on this.

Common trap> when you meant >>, which silently wipes the file you wanted to add to.

A question to check yourself, an AI practice session and 1 cheat sheet entry come when you add the roadmap to your account. Add it

Resources for this stage

Start with· follow one of these

Practise

  • A game played over SSH where each level needs a new command, from `ls` to finding hidden files

Keep handy

  • Paste any command and see what each part does before you run it

  • Short, example-first help pages for common commands when a man page is too long

Also worth your time

Mark this stage as not done?