Loading
0x140Lesson 21 of 28

Archives, links and disk space

Pack files with tar, link them with ln, and find out what’s filling the disk.

24 min 5-question quiz 1 code exercise
By the end of this lesson you can
  • Create, list and extract archives with tar and gzip
  • Explain symbolic links and hard links
  • Find what’s using disk space with df and du

tar: many files, one bundle

tar bundles files together, and -z compresses the result with gzip. The flags spell out what you want:

CommandMeaning
tar -czf backup.tar.gz logs/create, gzip, to this file
tar -tzf backup.tar.gzlist what’s inside, without unpacking
tar -xzf backup.tar.gzextract into this folder

Always list an archive from someone else before extracting it. Some unpack dozens of files straight into your current folder.

A symbolic link is a signpost: a tiny file that holds a path. Create one with ln -s target linkname. Delete the target, and the link dangles, pointing at nothing. Symlinks are everywhere, and a common use is a current link that points at the latest release.

A hard link (ln target linkname) is a second name for the same data. The data stays until the last name is gone, but hard links can’t cross filesystems or point at folders.

Try it

Up to 15 XP

Symlink or hard link?

Decide which kind of link each statement describes.

0 of 5 sortedScore 0/0
  • “Breaks if the original file is deleted.”

  • “Can point at a folder.”

  • “The data survives until every name is removed.”

  • “Can point to a different disk.”

  • “Shown by ls -l with an arrow: current -> releases/v2”

What’s filling the disk?

A full disk is one of the most common server emergencies, and it causes odd failures everywhere. Two commands find it: df -h shows how full each filesystem is, and du -sh * shows what’s taking the space in the current folder. Start at the top and work your way down the biggest folders.

Try it

Up to 15 XP

The disk is 97% full

An alert just fired. Find the problem, and fix it without deleting anything important.

Mission 1 of 3

Confirm the alert

Night shift: “Monitoring says the disk is nearly full. Check it, and tell me the percentage used.”

Simulated shell. Try ls, or type help to see the commands.

/home/crew/server
  • app
    • current.jar
  • database
    • orders.db
  • logs
    • app.log
    • debug-2026-10.log
Up arrow: history. Tab: complete. Ctrl-L: clear. Ctrl-C: cancel.
  1. Confirm the alert
  2. Find the biggest folder
  3. Clear the space safely

Key takeaways

  • tar -czf creates, -tzf lists and -xzf extracts.

  • A symlink is a path, and a hard link is another name for the same data.

  • df shows how full a disk is, and du shows what’s using it.

Lesson quiz

5 questions · pass with 4 correct · up to 50 XP

Passing this quiz completes the lesson and keeps your streak going. Questions you miss come back in review sessions later.

Practice: write Bash scripts

Write a script in the editor and run it for real against sample input. Each run gets a fresh Linux sandbox with Bash 5.2 and the GNU tools on Wandbox, a free public service - so experiment freely, even with rm. Your script and test input are sent there.

Exercise 1

Pack the logs

+25 XP

The starter makes a logs folder with three files. Create logs.tar.gz from it, then remove the folder. Finally list the archive’s files in sorted order (leave out the folder entry itself), then print archived N files.

  • Lists three files
script.sh
Loading editor…

Your script runs with Bash 5.2 and GNU tools on Wandbox, a free public service, in a fresh sandbox each time. Your script and test input are sent to that service.

Questions about this lesson

Stuck? Ask. Figured something out? Share it. Explaining is one of the best ways to learn.

Loading posts…