terminal.cab

Terminal start Lesson 12 of 12

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

Final scenario: tidying up Downloads

15 minutes

Learning goals

Reading the long list: ls -l

ls -l shows one line per file. Before you change anything, it tells you what is there:

ls -l Downloads

Purpose: Lists files with permissions, owner, size and date.

Syntax: ls -l [FOLDER]

Example:

ls -l Downloads
total 636
-rw-r--r-- 1 lerner lerner 120000 Aug 10 18:05 'beach(1).jpg'
-rw-r--r-- 1 lerner lerner 120000 Aug 10 18:00  beach.jpg
-rw-r--r-- 1 lerner lerner  41000 Aug 31 10:00  invoice-2026-08.pdf
-rw-r--r-- 1 lerner lerner  42000 Sep 30 10:00  invoice-2026-09.pdf
-rw-r--r-- 1 lerner lerner  43000 Oct 15 10:02 'invoice-2026-10(1).pdf'
-rw-r--r-- 1 lerner lerner  43000 Oct 15 10:00  invoice-2026-10.pdf
-rw-r--r-- 1 lerner lerner   3000 Nov  2  2025  movie.mp4.part
-rw-r--r-- 1 lerner lerner  52000 Mar  1  2026  rental-contract.pdf
-rw-r--r-- 1 lerner lerner  95000 Aug 11 20:30  sunset.jpg
-rw-r--r-- 1 lerner lerner  64000 May 20 09:00  tax-return-2025.pdf
-rw-r--r-- 1 lerner lerner   1200 Dec 19  2025  update.zip.part

in the glossary: ls

From left to right: the permissions (-rw-r--r--), the number of links, the owner and the group (lerner), the size in bytes, the date of the last change and the name. Files older than half a year show the year instead of the time. That is how you spot the two .part files from last year: downloads that never finished.

The permissions read like this. The first character is the type: - for a file, d for a folder. Then come three groups of three: what the owner may do, what the group may do, what everyone else may do. r is read, w is write, x is execute, - is not allowed. rw-r--r-- means: you may read and change the file, everybody else may only read it.

Looking ahead: permissions and sudo

Remember Permission denied from lesson 8? That is these columns at work. Changing permissions with chmod and running a command as the administrator with sudo come in the path Linux Basics. Until then one rule is enough: sudo turns off the protection that permissions give you. Never put it in front of a command just because something did not work, and least of all in front of rm.

Finding duplicates

When you download a file twice, the browser saves the second one with (1) in the name. find with a pattern finds them all at once. The quotes are needed because of the star and the brackets:

find Downloads -name '*(1)*'

Purpose: Finds the copies a browser saved with (1) in the name.

Syntax: find FOLDER -name 'PATTERN'

Example:

find Downloads -name '*(1)*'
Downloads/invoice-2026-10(1).pdf
Downloads/beach(1).jpg

in the glossary: find

Is the copy really the same? (1) in the name, the same size and almost the same time in ls -l are hints, but not proof: two different files can have the same name, the same size and appear one after the other. Only the same content makes a real copy. For this exercise that is given: the two files with (1) are identical copies of their originals. uniq -c from lesson 11 would not help with comparing, because it compares lines of text, not whole files.

Sorting with a pattern

A pattern moves many files at once. But it takes everything that matches, also the copy with (1):

mv Downloads/invoice-*.pdf Downloads/invoices/

Purpose: Moves every file that matches the pattern into a folder.

Syntax: mv PATTERN FOLDER/

Example:

mkdir Downloads/invoices
mv Downloads/invoice-*.pdf Downloads/invoices/
ls Downloads/invoices
 invoice-2026-08.pdf  'invoice-2026-10(1).pdf'
 invoice-2026-09.pdf   invoice-2026-10.pdf

in the glossary: mv

That is why you delete the duplicates first, or check with ls and the same pattern which files will move.

The task

Tidy up Downloads in one go. The terminal keeps its state between your commands, so every step builds on the last one.

  1. Look at the folder with ls -l Downloads.
  2. Create the folders Downloads/invoices and Downloads/photos.
  3. Find the duplicates with (1) in the name and delete them. Here they are given as identical copies.
  4. Move the three invoices into invoices and the two photos into photos.
  5. Look at the old .part files with ls -l, then delete them.

tax-return-2025.pdf and rental-contract.pdf stay exactly where they are, unchanged.

Terminal task

Tidy up Downloads. Create the folders invoices and photos in Downloads. Delete the duplicates with (1) in the name; in this exercise they are given as identical copies of their originals. Move the three invoices into invoices and the two photos into photos. Delete the two unfinished .part downloads. tax-return-2025.pdf and rental-contract.pdf stay where they are, unchanged.

Task 1/1: Tidy up Downloads. Create the folders invoices and photos in Downloads. Delete the duplicates with (1) in the name; in this exercise they are given as identical copies of their originals. Move the three invoices into invoices and the two photos into photos. Delete the two unfinished .part downloads. tax-return-2025.pdf and rental-contract.pdf stay where they are, unchanged.

Tidy up Downloads. Create the folders invoices and photos in Downloads. Delete the duplicates with (1) in the name; in this exercise they are given as identical copies of their originals. Move the three invoices into invoices and the two photos into photos. Delete the two unfinished .part downloads. tax-return-2025.pdf and rental-contract.pdf stay where they are, unchanged.

Loading terminal …

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

Esc, then Tab leaves the terminal

Not done yet

Find the error

This line should move the invoices. Afterwards the tax return and the rental contract are in the invoices folder too. Tap the part that is wrong.

Parts of the command

Check works once you have tapped a part.

Fill the gap

In the permissions -rw-r--r--, the letter w stands for .

In the permissions -rw-r--r--, the letter w stands for ….

Check works once you have typed an answer.

What you can do now

That was Terminal Start. You can read the prompt and find your way with pwd, ls and cd. You create, view, copy, move and delete files, and you look before you delete. You know where to find help, you type less with Tab and the history, you search with grep and find, and you chain commands with pipes and redirections.

The next path, Linux Basics, builds on exactly this: permissions and sudo, processes, editors and the system around your home folder.

Quiz

  1. Question 1 of 3Which step comes last when you tidy up a folder?

    Check works once you have chosen an answer.

  2. Question 2 of 3ls -l shows beach(1).jpg with the same size and almost the same time as beach.jpg. What does that tell you?

    Check works once you have chosen an answer.

  3. Question 3 of 3rm answers "Permission denied". What is the right reaction?

    Check works once you have chosen an answer.

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: 3 exercises, 3 quiz questions

Back to the path

What you can do now: ls -l Downloads, find Downloads -name '*(1)*', mv Downloads/invoice-*.pdf Downloads/invoices/

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

Back to the path 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

The most important command lines of this path on one A4 page, black and white, to print or keep on your phone.