The disk is nearly full
Your laptop is slow. The disk is nearly full. You want to email a big folder, but it is too big to send. You also think you might have a virus.
What can you do? You use small helper programs. They are called utilities. They look after the computer, so that other programs can do their work.
Key words
| Word | What it means | Example |
|---|---|---|
| Utility | A small program that looks after the computer. | A backup tool |
| File management | Making, naming, moving, copying and deleting files and folders. | File Explorer |
| Fragmented | Split into pieces that are far apart on a disk. | A file in 50 pieces |
| Defragmenter | A utility that joins each file's pieces together again. | Defragment and Optimise Drives |
| Lossless | Compression that keeps every bit of the data. | ZIP |
| Lossy | Compression that throws away some detail for ever. | JPEG, MP3 |
| Compression | Making a file smaller so it uses less space. | A ZIP file |
| Package manager | A utility that finds, installs, updates and removes software. | The app store on a phone |
| Malware | Software made to harm a computer or steal data. | A virus |
| Firewall | A program that blocks unwanted data from reaching the computer. | The Windows firewall |
| Backup | A copy of files kept in another place. | A copy on a cloud drive |
The cells students fill in are left blank in this preview.
Match the utility to its job
Have a go
Loading…
Your answers are marked here and are not kept. A college account keeps every student’s marks.
Quick check
Have a go
Quick check
3 questionsClear names and folders save time
A file manager shows your files in folders. You can make a folder, rename a file, move it, copy it, search for it and delete it.
Good habits save time. Give files clear names. Keep a folder for each subject. Do not keep ten copies of one file with names like "final2" and "final3".
A defragmenter joins the pieces of a file
A hard disk saves a file in whatever free space it finds. After many saves and deletes, one file can be in many pieces. The file is now fragmented. The disk must move to many places to read it, so it is slower.
A defragmenter moves the pieces so each file is in one place. This helps a magnetic hard disk. An SSD has no moving parts, so it does not need it.
Try it: how many pieces?
# Each letter is a block of a file. A dash is free space.
disk = ["A", "-", "B", "A", "-", "B", "A"]
pieces = 0
last = "-"
for block in disk:
if block == "A" and last != "A":
pieces = pieces + 1
last = block
print("File A is in", pieces, "pieces")
# Put the three A blocks next to each other and run it again.
# A defragmenter does that for every file.
Make a free account to save your work and track your progress.
Compression makes files smaller
Compression makes a file smaller. A smaller file saves space and is faster to send.
A ZIP file holds one or many files in a smaller space. You open it to get the exact files back. Compression is useful for storage, and for an email attachment that is too big.
Extra: Lossless and lossy
Lossless compression keeps every bit of the data. A ZIP file is lossless, so you get the exact file back.
Lossy compression throws away detail that people hardly notice. A JPEG photo or an MP3 song is lossy. You cannot get the lost detail back.
Extra: Worked example: shrink a message
| Step | What to do | Result |
|---|---|---|
| 1 | Start with the text | AAAABBBCCD |
| 2 | Count each run of the same letter: 4 A, 3 B, 2 C, 1 D | 4 3 2 1 |
| 3 | Write each count and then its letter | 4A3B2C1D |
| 4 | Count the characters: 10 before, 8 after | 2 characters saved |
The cells students fill in are left blank in this preview.
Extra: Try it: a simple compression idea
# Write each run of the same letter as a count and the letter.
text = "AAAABBBCCD"
result = ""
previous = ""
count = 0
for letter in text:
if letter == previous:
count = count + 1
else:
if count > 0:
result = result + str(count) + previous
previous = letter
count = 1
result = result + str(count) + previous
print(text, "becomes", result)
Make a free account to save your work and track your progress.
Extra: Make a file with lots of numbers
seq 1 20000 > numbers.txtA command for the lesson’s lab terminal. It is shown here and not run.
Extra: Compress it with gzip
gzip -kf numbers.txtA command for the lesson’s lab terminal. It is shown here and not run.
Extra: Compare the sizes
ls -l numbers.txt numbers.txt.gzA command for the lesson’s lab terminal. It is shown here and not run.
Extra: What you saw
Note
The number in the fifth column is the size in bytes. The .gz file is much smaller, because the digits repeat a lot. gzip is lossless, so you can open the compressed file and get every digit back.
A package manager installs software
A package manager installs software from a trusted list. It also updates and removes it.
On Ubuntu it is called apt. You ask for a program by name. The package manager gets it and any other parts it needs.
Extra: More package managers
Note
Python has its own package manager, called pip. Windows has one called winget. The app store on a phone does the same job.
Extra: Count the installed packages
dpkg -l | wc -lA command for the lesson’s lab terminal. It is shown here and not run.
Block malware and keep a copy
Protection software includes anti-malware and a firewall. Anti-malware scans files for known malware. A firewall blocks unwanted data from reaching your computer.
Backup software copies your files to another place at set times. Keep one copy away from the room the computer is in.
Your turn: write a defragmenter
Write the function defragment. It gets a list of blocks. A letter is a block of a file. A dash is free space.
- Give back a new list.
- Put the blocks of each file together, in alphabet order. Use sort().
- Put all the free space at the end.
For example, ["A", "B", "A", "B"] becomes ["A", "A", "B", "B"]. Press Run Tests to check.
def defragment(disk):
# disk is a list of blocks. A letter is a block of a file. "-" is free space.
# Give back a new list: the blocks of each file together (in alphabet order),
# and all the free space at the end.
return disk
Make a free account to save your work, or press Start lab to work through the whole lesson.
True or false?
Have a go
True or false?
5 questionsFinal check
Have a go