Archives, links and disk space
Pack files with tar, link them with ln, and find out what’s filling the disk.
- 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:
| Command | Meaning |
|---|---|
tar -czf backup.tar.gz logs/ | create, gzip, to this file |
tar -tzf backup.tar.gz | list what’s inside, without unpacking |
tar -xzf backup.tar.gz | extract into this folder |
Always list an archive from someone else before extracting it. Some unpack dozens of files straight into your current folder.
Links: two names, one file
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 XPSymlink or hard link?
Decide which kind of link each statement describes.
“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 XPThe 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.
- app
- current.jar
- database
- orders.db
- logs
- app.log
- debug-2026-10.log
- Confirm the alert
- Find the biggest folder
- 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.
Pack the logs
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
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…