Technical skill

Linux command: df

Check how much storage remains

When a program cannot save a file, first find out whether the storage area containing that file has room. df reports used and available space for mounted filesystems. A filesystem is the structure that organizes files; mounting attaches it to a path so programs can reach its contents. With no path, df lists the mounted filesystems visible from the current environment. Give it a file or directory to check the filesystem that contains that path. For example, df -h /var/lib/myapp shows the storage relevant to that application.

Read the space report

The -h option prints sizes in units that are easier to read. The columns usually show filesystem name, total size, used space, available space, percent used, and mount point, the path where the filesystem is attached. Follow the mount point that contains the actual file. A high Use% means little capacity remains; Avail is often the number that matters when a program tries to create data. It can differ from total size minus used space because a filesystem may reserve blocks or use accounting rules. A container can have a separate mount namespace, meaning it sees a different set of mounted filesystems from another computer's view.

Bytes are not the only limit. Filesystems also track file records called inodes. A filesystem can have unused bytes but no free inodes, leaving it unable to create another file. df -i shows inode totals and usage. A full inode supply often points to a directory tree with many small files.

On GNU/Linux, df -T adds the filesystem type. df -hT /var/log combines that information with a space report for one path. These options and type names depend on the implementation. The type may help distinguish a local disk from a network or virtual filesystem, but it does not show mount options or quota rules.

Find what is using space

df measures the whole filesystem. du estimates the space used by files and directories it can visit. du -sh /var/log/* compares the immediate entries in a log directory. Its total may differ from df because of hard links (multiple names for the same file), reserved blocks, mount boundaries, permissions, metadata, or a deleted file that a running process still has open.

A useful investigation is to run df -h, note the mount point, check df -i, and inspect likely folders with du. Confirm which service owns the data and its retention policy before removing anything. After an approved cleanup, rerun df for the same path. If space use remains high, look for deleted files held open by processes or data outside the directory tree inspected. df is a snapshot of filesystem accounting. It does not show which process will write next, a user's quota, or a limit set by an application; check the relevant mount and service settings for those limits.

Interactive exercises

Materials

Skillsets
Skillset Linux administrator preview
image descriptionLinux administrator
by Infinite Education
3080 users
Skillset Devops preview
image descriptionDevops
by Ajay Kumar
2004 users
Skillset Skyeng Senior Backend Developer preview
image descriptionSkyeng Senior Backend Developer
by Artem Naumenko (slack2)
39 users
Skillset Linux for backend developer preview
image descriptionLinux for backend developer
by Artem Naumenko (fb)
16 users
Skillset Skyeng QA Automation Hard Skillset v09.21 preview
image descriptionSkyeng QA Automation Hard Skillset v09.21
by Aleksandra Kulikova
16 users
Show more
Do you know that ...?
Any useful or interesting facts about the skill. Any peace of information would be useful