terminal.cab

Terminal start Lesson 9 of 12

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

Faster

10 minutes

Learning goals

Tab completes

Type the start of a name and press Tab. If only one file or folder fits, the terminal writes the rest. If several fit, nothing happens at first; press Tab a second time and you see the choices. In this course they also appear as chips you can tap.

Tab even takes care of awkward names. cat Doc, Tab, Hol, Tab gives you this line, with a backslash before the space:

cat Documents/Holiday\ 2027.txt

Purpose: What Tab writes for you after cat Doc, Tab, Hol, Tab.

Syntax: Tab

Example:

cat Documents/Holiday\ 2027.txt
Where: the coast
When: July
Budget: 1200

in the glossary: cat

The history: arrow keys and Ctrl-R

The up arrow brings back your last command, press it again for the one before. The down arrow goes forward again. You can change the line before you press Enter. history shows the whole list:

history

Purpose: Lists your earlier commands with a number.

Syntax: history

Example:

ls Downloads
invoice.pdf  photo.jpg
history
    1  ls Downloads
    2  history

in the glossary: history

Is the command further back? Press Ctrl-R and type a piece of it, for example 404. The terminal shows the newest command that contains it. Enter runs it right away, Esc puts it on the line so you can change it first.

Ctrl-C and Ctrl-L

clear

Purpose: Clears the screen. Ctrl-L does the same.

Syntax: clear

Example:

clear

in the glossary: clear

On the phone

The bar above the keyboard has the keys a phone lacks. Tab and the arrows are right there. For Ctrl, tap Ctrl in the bar and then the letter on the keyboard: Ctrl, then c is Ctrl-C. Below the terminal, the chips under "Recent commands" are your history to tap.

Practice

Terminal task 1/3

Show the holiday plan in Documents with cat. Let Tab write the name: cat Doc, Tab, Hol, Tab, Enter.

Task 1/3: Show the holiday plan in Documents with cat. Let Tab write the name: cat Doc, Tab, Hol, Tab, Enter.

Show the holiday plan in Documents with cat. Let Tab write the name: cat Doc, Tab, Hol, Tab, Enter.

Loading terminal …

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

Esc, then Tab leaves the terminal

Not done yet

Terminal task 2/3

Run grep 404 projects/website/server.log. Then bring the line back with the up arrow, add > errors.txt at the end and press Enter. The hits should end up in errors.txt in your home folder.

Task 2/3: Run grep 404 projects/website/server.log. Then bring the line back with the up arrow, add > errors.txt at the end and press Enter. The hits should end up in errors.txt in your home folder.

Run grep 404 projects/website/server.log. Then bring the line back with the up arrow, add > errors.txt at the end and press Enter. The hits should end up in errors.txt in your home folder.

Loading terminal …

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

Esc, then Tab leaves the terminal

Not done yet

Terminal task 3/3

Show the first 3 lines of projects/website/server.log with head -n 3. Clear the screen with Ctrl-L. Then press Ctrl-R, type head and press Enter to run the line again.

Task 3/3: Show the first 3 lines of projects/website/server.log with head -n 3. Clear the screen with Ctrl-L. Then press Ctrl-R, type head and press Enter to run the line again.

Show the first 3 lines of projects/website/server.log with head -n 3. Clear the screen with Ctrl-L. Then press Ctrl-R, type head and press Enter to run the line again.

Loading terminal …

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

Esc, then Tab leaves the terminal

Not done yet

Fill the gap

To throw away the line you are typing and get a fresh prompt, press Ctrl-.

To throw away the line you are typing and get a fresh prompt, press Ctrl-….

Check works once you have typed an answer.

Put in order

You want to change a long command from earlier before running it again. Put the steps in order.

Steps

  1. Type a piece of the old command.
  2. Press Esc to put the hit on the line.
  3. Change the line and press Enter.
  4. Press Ctrl-R.

From now on, try to type no path in full. Next up: finding things in files and folders.

Quiz

  1. Question 1 of 4You type cd Do and press Tab. Nothing happens, because Documents and Downloads both fit. What now?

    Check works once you have chosen an answer.

  2. Question 2 of 4Which keys clear the screen without losing your history?

    Check works once you have chosen an answer.

  3. Question 3 of 4How do you press Ctrl-C on the phone in this course?

    Check works once you have chosen an answer.

  4. Question 4 of 4Which ways bring back a command you ran earlier? 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 10, Searching (10 min)

What you can do now: cat Documents/Holiday\ 2027.txt, history, clear

+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: open
  9. Lesson 9: done
  10. Lesson 10: open
  11. Lesson 11: open
  12. Lesson 12: open
1 of 12

Next: lesson 10, Searching (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