Learn › Linux Foundations › I/O Redirection
bash - a hands-on Linux lab on a real virtual machine.
The I/O Redirection module capstone mission. Drill , , <, 2, /dev/null, 2&1, &, pipes, pipe chains, tee, and combining redirects in one hands-on operation on a real Linux VM. Mission mode: no commands shown, recall required.
You have finished the I/O Redirection module. Every operator you need is already yours: the greater-than sign to save a command's output, the doubled form to add to a file, the less-than sign to feed a file into a command, the two-with-greater form to route the error channel, dev-null to throw a stream away, the merge that folds errors into normal output, the ampersand shorthand that catches both at once, the vertical bar that chains commands, and the tee that copies a stream while it flows.
This is the final run. One real machine, twelve objectives, and every one of them uses a move you already trained. Nothing new is introduced here.
This is mission mode. No commands are shown. You read the objective, recall the operator, and type it. That recall is the whole point: it is how stream routing becomes second nature. Progress checks itself as you go, and a signal is one click away if you get stuck.
Two quick reps in the practice terminal before the real machine boots. These boxes are a safe sandbox stocked with the same tiny files (fruits.txt, numbers.txt). Same rule as the mission: the goal is stated, the operator is not.
First rep. Count the lines in fruits.txt, but feed the file into the counter with a redirect so the counter never sees a filename, only the stream.
prompt: student@linuxcamp:~$ answer: wc -l < fruits.txt output: 5 hint: The line counter is wc -l. Feed it standard input from a file with the less-than operator: wc -l < fruits.txt.
Second rep. numbers.txt has repeats. Chain two commands with a pipe so the second reads the first's output: sort the numbers, then collapse the duplicates.
prompt: student@linuxcamp:~$ answer: sort numbers.txt | uniq output: 1 3 4 5 9 hint: Run sort on numbers.txt, then pipe its output into uniq with the vertical bar: sort numbers.txt | uniq.
Both came from memory: < fed a file into a command as its input, and | chained one command's output straight into the next. Those two operators, plus the save-and-route family, are the whole mission. Twelve objectives on the live machine next.
Both moves came from recall, not a copy button. That is what the mission demands, twelve times over: save output, append, feed input, split the error channel, discard a stream, merge the two, and copy a stream while it flows.
On this machine, a small script named report.sh always prints two ordinary lines and one error line, so you have a steady source to route, alongside the tiny fruits, colors, and numbers files. Boot the machine below and run the operation. No commands shown, progress checks itself as you type.
Practice Operation Signal in a real Linux terminal at The Linux Camp. Progress is verified automatically as you type commands on the machine.