Linux Basics Lesson 30 of 38
Disk full, but of what?
10 minutes
Learning goals
- Confirm a full disk with df and narrow it down with du.
- Make space without touching the running log, and confirm it.
- Get one file back from a backup without overwriting anything.
Three things stay as they are: the running log /var/log/app/app.log, the backup under /var/backups, and /etc/app/app.conf. The colleague wants to compare the configuration first and deal with it personally, so the file from the backup goes to ~/restore only. If you hit one of the three, the current step stays open. Undo or Start over takes you back.
find, gzip, sudo, sort and head are not on this page. gzip and sudo answer with a hint, find, sort and head with command not found. You can manage with df, du, ls, rm, mkdir and tar.
You can delete the old log here without sudo, because the folder /var/log/app lets the group adm write, and lerner is in it. Whether you may delete a file is decided by the rights on its folder, not on the file itself. On a real server, that folder usually does not let you write, and deleting needs sudo.
Steps
Step 1/4: Confirm the alarm first. How full is the disk that / is on? Step 2/4: Narrow it down. Which file under /var/log/app takes up the space? Step 3/4: Make space. The running log stays, and df has the last word. Step 4/4: Now for your colleague. Get app.conf out of /var/backups/app-config-2026-10-16.tar.gz and put it under ~/restore. /etc/app/app.conf stays as it is. Scenario solved
07:10. / is at 97 %, and the database refuses to write. In five minutes this escalates. On top of that, a colleague asks for yesterday's app configuration from the backup, because someone has wrecked the current one. Find what is eating the disk, make space, and get the file out, without breaking anything else.
-
Step 1 done solved before
Confirm the alarm first. How full is the disk that / is on?
Hint 1: df shows how full file systems are. -h makes the numbers readable.Hint 2: Type df -h /Solution
df -h /Why: 97 % of 40 GiB, and only 1.4 GiB are left. Now you know that the alarm is real and that it is about /, not about /tmp.
See the solution? You get fewer XP for this scenario.
Start over? The whole scenario goes back to step 1. Your hints stay, XP only comes once.
-
Step 2 done solved before
Narrow it down. Which file under /var/log/app takes up the space?
Hint 1: du -a also lists single files. Folders you may not read only cause messages, 2>/dev/null hides those.Hint 2: Type du -ah /var/log/appSolution
du -ah /var/log/appWhy: 29G in app.log.1, the rotated log, and only 1.9G in the running one. On a real server, find /var -size +1G would have taken you straight there as well.
See the solution? You get fewer XP for this scenario.
Start over? The whole scenario goes back to step 1. Your hints stay, XP only comes once.
-
Step 3 done solved before
Make space. The running log stays, and df has the last word.
Hint 1: First ls -lh, so that you see what you are deleting. Then rm with the full name, no pattern. Then df again.Hint 2: Type ls -lh /var/log/app, then rm /var/log/app/app.log.1, then df -h /Solution
ls -lh /var/log/app rm /var/log/app/app.log.1 df -h /Why: From 97 % to 25 %, and the database can write again. A pattern like app.log* would have taken the running log along. Moving the file would not have helped, because it would still be on the same disk.
See the solution? You get fewer XP for this scenario.
Start over? The whole scenario goes back to step 1. Your hints stay, XP only comes once.
-
Step 4 done solved before
Now for your colleague. Get app.conf out of /var/backups/app-config-2026-10-16.tar.gz and put it under ~/restore. /etc/app/app.conf stays as it is.
Hint 1: -C needs a folder that already exists. Without mkdir -p ~/restore, tar stops with Cannot open. Look inside with -tzf first.Hint 2: Type tar -tzf on the archive, then mkdir -p ~/restore, then tar -xzf on the archive with -C ~/restoreSolution
tar -tzf /var/backups/app-config-2026-10-16.tar.gz mkdir -p ~/restore tar -xzf /var/backups/app-config-2026-10-16.tar.gz -C ~/restoreWhy: The file is now in ~/restore/etc/app/app.conf, next to the broken one and not on top of it. Your colleague can compare them. The path in the archive stays the same, and -C only decides where it starts.
See the solution? You get fewer XP for this scenario.
Start over? The whole scenario goes back to step 1. Your hints stay, XP only comes once.
Scenario solved
Why each step mattered
- Step 1: 97 % of 40 GiB, and only 1.4 GiB are left. Now you know that the alarm is real and that it is about /, not about /tmp.
- Step 2: 29G in app.log.1, the rotated log, and only 1.9G in the running one. On a real server, find /var -size +1G would have taken you straight there as well.
- Step 3: From 97 % to 25 %, and the database can write again. A pattern like app.log* would have taken the running log along. Moving the file would not have helped, because it would still be on the same disk.
- Step 4: The file is now in ~/restore/etc/app/app.conf, next to the broken one and not on top of it. Your colleague can compare them. The path in the archive stays the same, and -C only decides where it starts.
Start over? The whole scenario goes back to step 1. Your hints stay, XP only comes once.
Loading terminal …
Esc, then Tab leaves the terminal
Step 1 of 4
Cards
-
Card 1 of 2
Tap the card or press Space to turn it over.
-
Card 2 of 2
Tap the card or press Space to turn it over.
Cheat sheet
The most important command lines of this module on one A4 page, black and white, to print or keep on your phone.
- Download PDF (PDF, 17 KB)
- View as image (PNG, 47 KB)