// Linux Basics

Pipes, grep and find

Combine small commands to discover useful information.

The pipe symbol | takes the output of one command and gives it to the next. It is one of Unix's most useful ideas.

A simple pipeline

ls -lah /etc | less

ls generates the listing; less lets you browse it page by page.

Search inside text

printf 'alpha\nbeta\nAlpha two\n' > ~/darkpc-list.txt
grep -in 'alpha' ~/darkpc-list.txt

grep -i ignores case and -n shows matching line numbers.

Find files by name

find ~/Documents -type f -name '*.txt'

The quotes matter: they prevent the shell from expanding *.txt too soon.

Count things

find ~/Documents -type f | wc -l

wc -l counts lines. File names containing newlines can make this count misleading, so treat it as an everyday shortcut, not a robust script.

Save output while reading it

uname -a | tee ~/darkpc-system.txt

tee sends output to both the terminal and a file. Experiment with grep, sort, uniq, head, and tail.

Safety note: a pipeline can do damage if its last command deletes or changes files. Inspect unfamiliar commands before running them.