Level 0 · Module 2
Command-line basics
Learn how a shell turns typed commands into operating-system actions.
Not completed
By the end, you can
- Distinguish a terminal, shell, command, argument, and option.
- Navigate and inspect files with basic commands.
- Explain standard input, output, errors, pipes, and exit status.
Summary
A terminal displays a text session; a shell reads commands and launches programs. Commands combine a program name with arguments and options.
Introduction
Graphical interfaces hide many operating-system details. The command line makes paths, processes, streams, and errors visible, providing a precise way to work and automate repeated steps.
Explanation
The shell parses a command line, expands supported syntax, locates a program, and asks the OS to start a process. The program receives arguments plus three standard streams: input, output, and error. A pipe connects one program’s output to another’s input. An exit status of zero conventionally means success; nonzero values describe failure. Exact commands differ between shells and operating systems.
Real-world example
grep error app.log runs the grep program with a search term and a file path. The shell starts
it; the program reads the file and writes matching lines to standard output.
Read a command
grep -i "error" app.log
│ │ │ │
program option argument argumentCode example
pwd # show current directory
ls # list directory entries
cd projects # change directory
printf 'hello
' | wc -l
echo $? # show the previous exit statusCommon mistakes
- Calling the terminal and shell the same component.
- Ignoring spaces, quoting, or the current working directory.
- Assuming visible output is the only result or that every command succeeded.
Quiz
Knowledge check
Try it
Build a safe command trace
Explain what the shell, OS, and each program do in printf 'one\ntwo\n' | wc -l, including the
expected output and exit status.
Key takeaways
- A terminal hosts a text session; a shell interprets command lines.
- Programs receive arguments and standard streams, then return an exit status.
- Paths, quoting, pipes, and careful target inspection are essential command-line habits.