UNIT 5: Command Line Essentials
The Terminal is not scary. It is a language. Once you know the grammar, you can speak it.
1. Command Syntax
Commands usually follow this structure: DO WHAT + HOW + TO WHAT.
ls
Command
-la
Flag / Option
/home
Argument
2. Getting Help (RTFM)
You cannot memorize every command. Use the built-in manuals.
- man ls : Opens the full manual for the 'ls' command.
- ls --help : Prints a quick cheat sheet to the screen.
3. Input/Output Redirection
Normally, commands print to the screen. You can force them to print to a file instead.
echo "Hello" > file.txt # SAVES "Hello" into file.txt
echo "World" >> file.txt # APPENDS "World" to the end
echo "World" >> file.txt # APPENDS "World" to the end
4. Pipes and Filters
The Pipe ( | ) passes the output of one command to another. This is the most powerful feature in Linux.
cat list.txt | grep "Learnix"
This reads the file list.txt AND searches for the word "Learnix" at the same time.
MISSION: Save the phrase "Mission Accomplished" into a file named log.txt