Lesson 6: Run programs safely and recover from mistakes
Lesson objectives:
- Add arguments and flags to a command.
- Find help with
--helpandman.- Interrupt a running command with
Ctrl+C.- Read a simple error message and fix the command.
Prerequisites: Lessons 01-05 | Previous << 05 | Next >> README
What if I type the wrong thing?
By now, you have run many commands. Most commands can be changed with extra pieces of information. An argument is a word that tells the command what to act on. A flag (or option) is a special switch that changes how the command behaves 12.
For example, ls lists files. ls -l lists files with details. ls -l Documents lists the details of files inside the Documents folder. Here, -l is a flag and Documents is an argument 1.
When you are unsure what a command can do, you have two reliable sources of help:
man lsopens the manual page forls32.ls --helpprints a short summary of options for many commands 2.
If a command seems to hang or is doing something you did not want, press Ctrl+C to stop it 1. This sends an interrupt signal and returns you to the prompt.
Security note: Never copy and run a command from the internet unless you understand what it does. If a command includes
rm,sudo, or>followed by a file path, pause and read it carefully.
Worked example (follow along)
Run these commands and watch the differences.
The -l flag changes the output to a long list. The -a flag shows hidden files, which start with a dot. Many flags can be combined: ls -la does the same thing as ls -l -a.
Now try getting help:
You will see a summary. If you want the full manual, try:
Scroll with arrow keys and press q to quit.
To see Ctrl+C in action, run a command that waits:
The ^C shows where you pressed Ctrl+C. The command stopped and the prompt returned.
Your turn (faded example)
You want to list all files, including hidden ones, in the current folder. Fill in the flag:
Answer: ls -a (or ls -la for a long list with hidden files).
Summary + what's next
Congratulations. You can now open a terminal, read the prompt, move around folders, inspect files, move and copy them, run commands with arguments and flags, find help, and recover from a wrong command. The terminal is no longer a black box of code; it is a text-based way to talk to your computer.
To keep going, practice the five commands you use most: pwd, ls, cd, cat, and mv. When you are comfortable, explore man pages for any command you see in a tutorial. You have the foundation to follow almost any beginner command-line guide without fear.
Footnotes
-
Apple Command Line Primer — https://developer.apple.com/library/archive/documentation/OpenSource/Conceptual/ShellScripting/CommandLInePrimer/CommandLine.html ↩ ↩2 ↩3
-
MDN: Command line crash course — https://developer.mozilla.org/en-US/docs/Learn_web_development/Getting_started/Environment_setup/Command_line ↩ ↩2 ↩3
-
MIT Missing Semester: Course Overview + Introduction to the Shell — https://missing.csail.mit.edu/2026/course-shell/ ↩