Back to commands

Hosting Operations

Read-only, can be slow

List Largest Files in a Backup

You need to rank backup files by size.

Command

find backup -type f -printf '%s %p\n' | sort -nr | head

Before you run this

System impact: Read-only. Can create load on large logs, directories, filesystems, or process tables.

When not to use it: Do not delete files just because they are large; confirm age, ownership, and restore value first.

Expected output

A largest-first list of backup files with byte counts.

System impact

Read-only, can be slow. Nothing changes. The command prints file sizes and paths sorted largest first.

Scope this to the smallest useful path or service on busy systems.

Recovery / rollback: no state is changed.

When to use it

Use when backups are growing or a storage bill suddenly changes.

When not to use it

Do not delete files just because they are large; confirm age, ownership, and restore value first.

Explanation-only example

Illustrated output, not a live lab run

This example is intentionally illustrative. It shows the command shape without killing real processes or changing your machine.

demo@lab:~$

$ find backup -type f -print | sort

backup/.snapshot
backup/app/config.yml
backup/content/index.md
backup/old-report.csv
backup/tmp/empty.cache

$ find backup -type f -printf '%s %p\n' | sort -nr | head

39 backup/app/config.yml
26 backup/content/index.md
13 backup/old-report.csv
0 backup/tmp/empty.cache
0 backup/.snapshot
View commands shown

These are the commands shown in the sanitized transcript.

Commands shown

  1. find backup -type f -print | sort
  2. find backup -type f -printf '%s %p\n' | sort -nr | head

next steps

Related commands

Hosting Operations Can be slow

Rank Old Cleanup Candidates by Size

The oldest file is not always the file that buys back meaningful space.

find /lab/disk-inode-cleanup/var -xdev -type f -mtime +7 -printf '%s %TY-%Tm-%Td %p\n' | sort -nr | head
Hosting Operations Can be slow

Find the Largest CI Artifacts

A bloated artifact can explain a slow or failed pipeline.

find artifacts -type f -printf '%s %p\n' | sort -nr | head -10
Hosting Operations Can be slow

Find Directories Burning Inodes

Inode cleanup starts by finding the directory with too many files.

find /lab/disk-inode-cleanup/var/cache/app -xdev -type f -printf '%h\n' | sort | uniq -c | sort -nr | head
Hosting Operations Can be slow

Find the Newest Build Logs First

The failing file is usually one of the newest artifacts.

find artifacts logs -type f \( -name '*.log' -o -name '*.txt' \) -printf '%TY-%Tm-%Td %TH:%TM %p\n' | sort -r | head
Hosting Operations Can be slow

Show Release Directory Ages

See your newest release directories without opening a dashboard.

find releases/ -mindepth 1 -maxdepth 1 -type d -printf '%T@ %TY-%Tm-%Td %TH:%TM %p\n' | sort -nr | head -10 | cut -d' ' -f2-
Study mapping

Use this as independent command practice: read the notes, predict the output, then compare it with the example before using a real shell.

  • lpic1:103-gnu-unix-commands
  • lpic1:104-filesystems-permissions-fhs
  • lfcs:essential-commands
  • lfcs:operations-deployment
  • lfcs:services-logs
  • lfcs:storage
  • linuxplus:automation-scripting
  • linuxplus:provisional
  • linuxplus:system-management
  • risk:read-only

Useful for

  • LPIC-1 style command-line practice
  • LFCS style performance tasks
  • Linux+ style troubleshooting review

Independent study support only. No affiliation, endorsement, exam dumps, or real exam questions.