C

Linux › Module 5 › Lesson 1

BeginnerModule 5Lesson 1/5

Pipes and Redirection (|, >, >>)

Chain commands with pipes and save output using redirection

15 min+40 XP3 quiz
Module progress1 of 5

Opening

One command is good. A chain is power.

Linux shines when you combine small tools. A pipe (|) sends one command's output into the next. Redirection (>, >>) saves results to a file. This is how analysts filter millions of log lines in seconds.

1. The Pipe: |

Read left to right—output flows through: ls -l | less — long list, scroll page by page cat access.log | wc -l — count lines in a file history | tail -5 — last five commands you ran

2. Redirect Output: > and >>

> creates or overwrites a file: echo "scan started" > status.txt >> appends without erasing: date >> status.txt echo "done" >> status.txt

3. stderr: 2>

Programs send normal output to stdout (1) and errors to stderr (2). command 2> errors.txt — save errors only command &> all.txt — save both streams

Blue team example

cat /var/log/auth.log | grep "Failed password" | wc -l Counts failed SSH logins—fast breach signal.

Knowledge Check

1

What does the pipe symbol | do?

Multiple choice

Knowledge Check

2

Which operator appends to a file without overwriting?

Multiple choice

Knowledge Check

3

True or False: You can chain more than two commands with pipes.

True or False

← Previous

Answer all 3 knowledge checks to continue. (0/3 answered)