Archives and compression

An archive turns a folder into a single file you can move or back up, and compression makes it smaller. These questions cover tar, gzip, and the listing you should always do before extracting anything you did not create.

4 questions 1 task Read the lesson

Questions

Each one is marked as you go, and the explanation arrives straight after, which is the part worth reading.

4 questions, marked as you go.

1 In tar -czf project.tar.gz project, what do the letters c, z and f ask for?
2 Why run tar -czf project.tar.gz project rather than tar -czf project.tar.gz project/*?
3 Why run tar -tzf on an archive before extracting one you did not create?
4 What does gzip a.txt leave behind?

Tasks

These need your own device. Run the command in Termux, then paste what it printed. The marking looks at what the output means, so spacing, version numbers and ordering do not matter. If you have not installed anything yet, the lesson covers the setup.

Pack a folder and list it back

This builds a small folder, packs it into a compressed tar archive, then lists the archive contents without extracting anything.

Run this in Termux On your own device. Nothing on this page executes it. The command runs in your terminal, and this box only reads what you paste back.

mkdir -p ~/project/notes; echo alpha > ~/project/a.txt; echo beta > ~/project/notes/c.txt; tar -czf ~/project.tar.gz -C ~ project; tar -tzf ~/project.tar.gz
Marking your own work Both halves of this are checked in your browser, with no server involved, so nothing stops you from pasting output you did not run. The tasks are written so that the easiest way to pass one is to actually do it and read the result, which is the whole intention.

All sets Read the lesson