Shrink the Logs

Linux lab Intermediate 5 tasks 20 points

The logs folder is taking up space. Compress a log on its own, see how small it gets, then pack the whole folder into a single compressed archive and prove you can read it back.

How it works: the terminal below is a real Linux machine running in your browser. Click it and type. Tasks tick themselves off as you complete them; questions are answered in the box under each task. Press Reset any time for a fresh machine. Your password on this machine (for sudo) is student.

student@vulntech:~ Starting…
Getting your Linux machine ready…
The first start downloads about 20 MB. After that your browser keeps it, and labs start in a moment.

Hints

Each compressor replaces the file and adds its own ending (.gz, .xz).

The repetitive log compresses enormously, which is the point of the example.

Solution explanation

gzip and gunzip compress and restore one file in place. xz squeezes the repetitive log down to a tiny fraction of its size. tar -czf logs.tar.gz logs bundles and gzips the whole folder at once, and tar -tzf lists it without extracting anything.

Show solution
gzip logs/day-01.log
gunzip logs/day-01.log.gz
cp logs/day-02.log d.log
xz d.log
ls -l d.log.xz logs/day-02.log
tar -czvf logs.tar.gz logs
tar -tzf logs.tar.gz
HOME LEARN COMMUNITY DASHBOARD