Powerful CLI Concepts
Complex tasks in Linux are often done by chaining simple commands together using Piping and Redirection.
Piping (|)
The pipe character takes the standard output (stdout) of one command and uses it as the standard input (stdin) for the next command.
Use Case: Searching the output of a lengthy command.
bash
List all processes and filter to only show processes containing 'ssh'
ps aux | grep ssh
Redirection (> and >>)
Redirection sends the output of a command to a file, rather than displaying it on the screen.
>: Overwrites the file.>>: Appends to the end of the file.
Use Case: Saving the results of a scan (critical during reconnaissance).
bash
Save a list of files to 'file_list.txt'
ls -l > file_list.txt
Append another list to the same file
ls /etc >> file_list.txt