terminal.cab

Terminal start Lesson 8 of 12

guestLevel 1Badges and progress0/100 XP, XP to the next levelStreak0

Getting help

10 minutes

Learning goals

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 rm

in the glossary: man

Inside, 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 exit

in the glossary: mkdir

What 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:

  • -a show every match, not only the first

Example:

type ls cd
ls is /usr/bin/ls
cd is a shell builtin

in the glossary: type

which 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/ls

in the glossary: which

Reading 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

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.

Loading terminal …

lerner@terminal: ~bash
lerner@terminal:~$

Esc, then Tab leaves the terminal

Not done yet

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.

Loading terminal …

lerner@terminal: ~bash
lerner@terminal:~$

Esc, then Tab leaves the terminal

Not done yet

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.

Loading terminal …

lerner@terminal: ~bash
lerner@terminal:~$

Esc, then Tab leaves the terminal

Not done yet

Put in order

You want to find the option of rm that deletes folders, in the manual. Put the steps in order.

Steps

  1. Read the line with -r, --recursive.
  2. Type man rm and press Enter.
  3. Type /recursive and press Enter.
  4. Press q to get back to the prompt.

Predict the output

Command

type cd

Before the command, in your home folder ~

  • ~/.bashrc
  • ~/.profile
  • ~/.config/
  • ~/Documents/
  • ~/Downloads/
  • ~/Pictures/
  • ~/notes.txt
  • ~/projects/
What does type cd print?

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

  1. Question 1 of 4You opened man ls and want to get back to the prompt. Which key?

    Check works once you have chosen an answer.

  2. Question 2 of 4cat Documents answers "Is a directory". What does that mean?

    Check works once you have chosen an answer.

  3. Question 3 of 4You type cta notes.txt and get "command not found". What is the most likely cause?

    Check works once you have chosen an answer.

  4. Question 4 of 4Which ways show you the options of ls on this computer? Choose TWO.

    Check works when exactly 2 are chosen. Chosen: 0.

Cards

  1. Card 1 of 4

    Tap the card or press Space to turn it over.

  2. Card 2 of 4

    Tap the card or press Space to turn it over.

  3. Card 3 of 4

    Tap the card or press Space to turn it over.

  4. 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

Next: lesson 9, Faster (10 min)

What you can do now: man rm, mkdir --help, type ls cd, which ls

+0 XP in this lesson

  1. Lesson 1: open
  2. Lesson 2: open
  3. Lesson 3: open
  4. Lesson 4: open
  5. Lesson 5: open
  6. Lesson 6: open
  7. Lesson 7: open
  8. Lesson 8: done
  9. Lesson 9: open
  10. Lesson 10: open
  11. Lesson 11: open
  12. Lesson 12: open
1 of 12

Next: lesson 9, Faster (10 min) That's enough for today

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