Terminal start Lesson 12 of 12
Final scenario: tidying up Downloads
15 minutes
Learning goals
- Plan a tidy-up in steps and carry it out with mkdir, mv, find and rm.
- Find duplicate downloads and old leftovers, look at them first, then delete them.
- Read the long listing of ls -l, including the permissions column.
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.partFrom 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).jpgIs 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.pdfThat 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.
- Look at the folder with
ls -l Downloads. - Create the folders
Downloads/invoicesandDownloads/photos. - Find the duplicates with
(1)in the name and delete them. Here they are given as identical copies. - Move the three invoices into
invoicesand the two photos intophotos. - Look at the old
.partfiles withls -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.
Task complete
Solution
ls -l Downloads
mkdir Downloads/invoices Downloads/photos
find Downloads -name '*(1)*'
rm 'Downloads/beach(1).jpg' 'Downloads/invoice-2026-10(1).pdf'
ls Downloads/invoice-*.pdf
mv Downloads/invoice-*.pdf Downloads/invoices/
mv Downloads/*.jpg Downloads/photos/
ls -l Downloads/*.part
rm Downloads/*.part Why: Small steps you can check beat one clever line. If something looks wrong after a step, you notice it before rm makes it permanent.
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.
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
-
Check works once you have chosen an answer.
-
Check works once you have chosen an answer.
-
Check works once you have chosen an answer.
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: 3 exercises, 3 quiz questions
What you can do now: ls -l Downloads, find Downloads -name '*(1)*', mv Downloads/invoice-*.pdf Downloads/invoices/
+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: open
- Lesson 9: open
- Lesson 10: open
- Lesson 11: open
- Lesson 12: done
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
-
ls -lpermissions, owner, size, date -
find <folder> -name '*(1)*'find duplicate downloads -
mv <pattern> <folder>/sort many files in at once -
ls <pattern>, then rm <pattern>look first, then delete
The most important command lines of this path on one A4 page, black and white, to print or keep on your phone.
- Download PDF (PDF, 31 KB)
- View as image (PNG, 137 KB)