>_ IzzyLab

Hands-on task

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

Which user is using up the space

medium~7 min

The shared folder /srv/shared holds files of three users — alice, bob and carol. Find out which of them uses the most space: compare the total size (in bytes) of all their files across the whole tree, including subdirectories and hidden files. Write the user name to /root/answer.txt.

What you'll practise:
  • find -printf
  • file owner
  • awk: summing
  • hidden files
  • disk usage analysis

Topic breakdown

du answers "how much does a directory take", but not "how much does a user take" when files of different owners are mixed in a shared tree. For that you list the files and sum the size per owner: find can print attributes using a format (-printf with owner and size directives), and awk accumulates totals in an associative array. What matters is the total: the user with the biggest file or the most files isn't necessarily the one using the most space. And remember that find sees hidden files, while shell globs by default don't.

What's checked

  1. found the user using the most space

What it looks like