Terminal start Lesson 8 of 12
Getting help
10 minutes
Learning goals
- Open a manual page with man, search in it and quit with q.
- Get the short help of a command with --help.
- Find out with type and which what is behind a command name.
- Read the four most common error messages and know what to do next.
The manual: man
man opens the manual page of a program, full screen, the same way less shows a file:
man rm
Purpose: Opens the manual page of a program, full screen.
Syntax: man PROGRAM
Example:
man rmInside, the keys from less work: Space for the next page, b to go back, / followed by a word and Enter to search,
n for the next hit, and q to quit. Try /recursive in man rm: it jumps straight to the option for folders.
The short help: --help
Most programs print a short overview of their options when you add --help. It lands right in the terminal, no full
screen:
mkdir --help
Purpose: Prints a short help with the options of a command.
Syntax: COMMAND --help
Example:
mkdir --help
Usage: mkdir [OPTION]... DIRECTORY...
Make each DIRECTORY, if it does not exist yet.
-p, --parents also make missing parent directories; no error if DIRECTORY exists
-v, --verbose print a line for every directory made
--help show this help and exitWhat is behind a name: type and which
Not every command is a program. cd is built into the shell itself. type tells you which kind a name is:
type ls cd
Purpose: Tells whether a name is a program, a shell builtin or an alias.
Syntax: type NAME...
Options:
Example:
type ls cd
ls is /usr/bin/ls
cd is a shell builtinwhich only looks for programs and prints their path. For a builtin like cd it prints nothing:
which ls
Purpose: Shows the path of the program that runs for a name.
Syntax: which PROGRAM...
Example:
which ls
/usr/bin/lsReading error messages
An error message has the same shape every time: the program, then what it was working on, then the reason. The reason is what matters:
cat notes
cat: notes: No such file or directory
cat Documents
cat: Documents: Is a directory
ls /root
ls: cannot open directory '/root': Permission denied
No such file or directory: the name or the path is wrong. Check withlsand watch for typos.Is a directory: you gave a folder where a file was expected. Uselsfor folders, or the option for folders.Permission denied: the file or folder exists, but you are not allowed in. More on that in the last lesson.command not found: the shell knows no program with that name. Usually a typo likectainstead ofcat, sometimes the program is not installed.
Practice
Terminal task 1/3
Find out where the program date lives. Let the terminal show you its full path.
Task 1/3: Find out where the program date lives. Let the terminal show you its full path.
Find out where the program date lives. Let the terminal show you its full path.
Task complete
Solution
which date Why: If a command behaves strangely, the first question is which program actually runs. which answers it in one line.
See the solution? You get fewer XP for this task.
Start over? Files, folders and output go back to the start. Your hints stay.
Loading terminal …
Esc, then Tab leaves the terminal
Not done yet
Repeat: you have solved this task before.
Terminal task 2/3
cat projects/website/index.htm answers "No such file or directory". Find the right name with ls and show the file.
Task 2/3: cat projects/website/index.htm answers "No such file or directory". Find the right name with ls and show the file.
cat projects/website/index.htm answers "No such file or directory". Find the right name with ls and show the file.
Task complete
Solution
cat projects/website/index.htm
ls projects/website
cat projects/website/index.html Why: "No such file or directory" almost always means a typo. ls on the folder shows the real names, and the mistake jumps out.
See the solution? You get fewer XP for this task.
Start over? Files, folders and output go back to the start. Your hints stay.
Loading terminal …
Esc, then Tab leaves the terminal
Not done yet
Repeat: you have solved this task before.
Terminal task 3/3
Show the short help of touch, right in the terminal, without full screen.
Task 3/3: Show the short help of touch, right in the terminal, without full screen.
Show the short help of touch, right in the terminal, without full screen.
Task complete
Solution
touch --help Why: --help is the fastest way to look up a forgotten option. You stay at the prompt and can type the command right away.
See the solution? You get fewer XP for this task.
Start over? Files, folders and output go back to the start. Your hints stay.
Loading terminal …
Esc, then Tab leaves the terminal
Not done yet
Repeat: you have solved this task before.
Put in order
You want to find the option of rm that deletes folders, in the manual. Put the steps in order.
Steps
- Read the line with -r, --recursive.
- Type man rm and press Enter.
- Type /recursive and press Enter.
- Press q to get back to the prompt.
Predict the output
Command
type cdBefore the command, in your home folder ~
- ~/.bashrc
- ~/.profile
- ~/.config/
- ~/Documents/
- ~/Downloads/
- ~/Pictures/
- ~/notes.txt
- ~/projects/
Check works once you have chosen an answer.
Open man ls in the terminal above, search for /sort and quit with q. Next up: how to type less and get more done.
Quiz
-
Check works once you have chosen an answer.
-
Check works once you have chosen an answer.
-
Check works once you have chosen an answer.
-
Check works when exactly 2 are chosen. Chosen: 0.
Cards
-
Card 1 of 4
Tap the card or press Space to turn it over.
-
Card 2 of 4
Tap the card or press Space to turn it over.
-
Card 3 of 4
Tap the card or press Space to turn it over.
-
Card 4 of 4
Tap the card or press Space to turn it over.
End of the lesson
Still open: 5 exercises, 4 quiz questions
What you can do now: man rm, mkdir --help, type ls cd, which ls
+0 XP in this lesson
- Lesson 1: open
- Lesson 2: open
- Lesson 3: open
- Lesson 4: open
- Lesson 5: open
- Lesson 6: open
- Lesson 7: open
- Lesson 8: done
- Lesson 9: open
- Lesson 10: open
- Lesson 11: open
- Lesson 12: open
Path complete
You finished all 12 lessons of Terminal start.
On to Linux Basics: lesson 1, Finding your way around a strange server (8 min) Back to the path
Cheat sheet
-
man <program>manual page, / to search, q to quit -
<command> --helpshort help with the options -
type <name>program, builtin or alias? -
which <program>path of a program