terminal.cab

Linux Basics Lesson 8 of 38

guestLevel 1Badges and progress0/100 XP, XP to the next levelStreak0

Disk usage 94% at 6:50

Rescue 80 XP

8 minutes

Learning goals

Go from coarse to fine: df says that it is tight, du says where. The app runs as your user on this machine, so you do not need sudo here. On most real servers you would, and that comes in module 5.

Why empty, not delete

On a real Linux system, a deleted file that a process still holds open does not give back its space. The name is gone, but the data stays on the disk until the process closes the file, usually at its next restart. So you run rm, df still says 94%, and you have lost the log as well. Emptying the file keeps the name and the open file, and the space is free at once.

This simulator does not model processes holding files open, so rm here would make df look fine. Do not let that fool you on a real server. That is exactly why this scenario treats rm as the wrong answer.

There are two ways to empty a file. truncate -s 0 FILE says what it does. > FILE has the same effect and is shorter, but one missing or extra character is expensive: > and >> look almost alike, and with the wrong file name you overwrite something you needed.

Steps

Step 1/4: Confirm that it really is tight. How full is the disk that / is on?

Rescue 80 XP

06:50. The monitoring wakes you: on web-01 only 6 percent of the disk are left. In a few hours the app will not be able to write any more. You want to know within a minute what is eating the space, and then get rid of it without taking the app down.

  1. Step 1

    Confirm that it really is tight. How full is the disk that / is on?

  2. Step 2

  3. Step 3

  4. Step 4

Loading terminal …

lerner@web-01: ~bash
lerner@web-01:~$

Esc, then Tab leaves the terminal

Step 1 of 4

Cards

  1. Card 1 of 3

    Tap the card or press Space to turn it over.

  2. Card 2 of 3

    Tap the card or press Space to turn it over.

  3. Card 3 of 3

    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.