>_ IzzyLab

Hands-on task

This task is step 3 of the course “Disks, links and free space”

Find the directory that ate up the space

medium~5 min

Under /root/data there are three subdirectories: app, logs, cache. One of them takes up far more disk space than the others. Determine which subdirectory is the largest by volume, and write its name (without the path) to the file /root/answer.txt.

What you'll practise:
  • du
  • sort
  • directory size
  • pipeline
  • basename

Topic breakdown

du computes how much space a directory actually occupies on disk; the summary-total flag gives one line per argument instead of a line-by-line listing of all nested files. After that it's a classic pipeline: numeric sorting in descending order brings the most "greedy" candidate to the top, and from the line you just need to pull out the directory name without the path (via basename or by trimming columns). The key idea is to compare aggregated volumes, not individual files.

What's checked

  1. the largest directory is found

What it looks like