ArticleslgStudy

science

Df (Unix)

Df (Unix) is a science topic covered in the lgStudy science library. This page brings together a partial reference excerpt, illustrations, worked examples, real-world applications and a short study plan, so you can understand Df (Unix) rather than just read about it. In short: df is a shell command for reporting the amount of available and consumed storage space on a file system. Although df is short for disk free, the command is not limited to disk storage.

Df (Unix) — main illustration
Df (Unix) — illustration

Key takeaways

  • Df (Unix) belongs to science; place it in that map before memorising details.
  • Learn the definition first, then one example that makes the definition concrete.
  • Connect Df (Unix) to a quantity you can measure, compute or draw — that is where exam questions come from.
  • Reproduce the core statement of Df (Unix) from memory before moving on to harder problems.

Reference excerpt

df is a shell command for reporting the amount of available and consumed storage space on a file system. Although df is short for disk free, the command is not limited to disk storage. It was developed during the long period of time when disk-based storage was the ubiquitous mass storage technology. The Single Unix Specification (SUS) specifies that space is reported in blocks of 512 bytes, and that at a minimum, it reports the file system names and the amount of free space. Using 512-bytes as the unit of measure is a historical practice and maintains compatibility with ls and other commands. Notably, the file system need not be constrained to internally use 512-byte blocks. The -k option was added as a compromise measure. It was agreed by the standard developers that 512 bytes was the best default unit because of its complete historical consistency on System V (versus the mixed 512/1024-byte usage on BSD systems), and that a -k option to switch to 1024-byte units was a good compromise. Users who prefer the more logical 1024-byte quantity can use alias to map df to df -k without breaking many historical scripts relying on the 512-byte units. The command first appeared in Version 1 AT&T Unix. The command is part of the X/Open Portability Guide since issue 2 of 1987. It was inherited into the first version of POSIX and the Single Unix Specification (SUS). The implementation of df bundled in GNU coreutils was written by Torbjorn Granlund, David MacKenzie, and Paul Eggert. The command is available for Windows via UnxUtils.

Use Any number of file parameters can be specified on the command line to select the storage for the file system containing the file. SUS specifies options -k and -P but most implementations include additional options. Notable options include:

-k Use 1024-byte units, instead of the default 512-byte units, when writing space figures. -P Output in portable format. -h The human-readable option selects to format sizes in metric units (e.g. 10 MB). Available in the BSD and GNU coreutils. -i Lists inode usage. Available in the BSD and GNU coreutils. -l Restricts reporting to local filesystems. Available in the BSD and GNU coreutils versions. -T Includes file system type information. Available in the GNU implementation.

Output The output with -P consists of a line of information for each specified file system, like:

⟨fs name⟩ ⟨total space⟩ ⟨space used⟩ ⟨space free⟩ ⟨percentage used⟩ ⟨fs root⟩

where:

⟨fs name⟩ The name of the file system, in an implementation-defined format. ⟨total space⟩ The total size of the file system in block size units. The exact meaning of this figure is implementation-defined, but should include ⟨space used⟩, ⟨space free⟩, plus any space reserved by the system not normally available to a user. ⟨space used⟩ The total amount of space allocated to existing files in the file system, in block size units. ⟨space free⟩ The total amount of space available within the file system for the creation of new files by unprivileged users, in block size units. When this figure is less than or equal to zero, it shall not be possible to create any new files on the file system without first deleting others, unless the process has appropriate privileges. The figure written may be less than zero. ⟨percentage used⟩ The percentage of the normally available space that is currently allocated to all files on the file system. This shall be calculated using the fraction: ⁠⟨space used⟩/⟨space used⟩ + ⟨space free⟩⁠ expressed as a percentage. This percentage may be greater than 100 if ⟨space free⟩ is less than zero. The percentage value shall be expressed as a positive integer, with any fractional result causing it to be rounded to the next highest integer. ⟨fs root⟩ The directory below which the file system hierarchy appears

Examples Example output from the df command:

See also du (Unix) – Shell command for reporting file system storage use List of POSIX commands

References

External links

df: report free disk space – Shell and Utilities Reference, The Single UNIX Specification, Version 5 from The Open Group

Manual pages df — manual page from GNU coreutils df(1): display free disk space – OpenBSD General Commands Manual The df Command – by The Linux Information Project (LINFO)

Illustrations

Df (Unix) illustration

Worked examples

Example 1 — a first encounter with Df (Unix)

Start with the simplest possible case. Write down what Df (Unix) claims or describes in one sentence, then invent the smallest concrete situation in which that sentence is true. In science, the smallest case is usually a single object, a single equation or a single measurement. Check that every symbol or term in your sentence has a meaning in that case.

Example 2 — changing one variable

Take the situation from Example 1 and change exactly one quantity: double it, halve it, or set it to zero. Predict what should happen to Df (Unix) before you calculate. Comparing your prediction with the result is the fastest way to find out whether you understand the idea or only the words.

Example 3 — an exam-style question

Typical questions about Df (Unix) ask you to (a) state it precisely, (b) apply it to given data, and (c) explain a limitation. Practise writing all three answers in under five minutes; the third part is what separates a full-mark answer from an average one.

Applications of Df (Unix)

In research
Df (Unix) appears in science research whenever the underlying quantities have to be modelled precisely. Papers usually cite it as a starting assumption and then explore where it breaks down.
In technology and industry
Engineering practice reuses Df (Unix) in design rules, simulations and safety margins. Knowing the idea lets you read a specification sheet and understand why the numbers look the way they do.
In the classroom
Df (Unix) is common in secondary-school and first-year university syllabi. It links to neighbouring topics Standard Unix programs, Unix SUS2008 utilities, so understanding it makes those chapters shorter.
In everyday life
Look for Df (Unix) outside the textbook — in sport, cooking, traffic, electronics or the sky above you. An example you found yourself is remembered far longer than one you were given.
Ask Teacher Smith questions about this articleOpens your AI tutor with a question about “Df (Unix)” →

How to study Df (Unix) in 20 minutes

  1. Read the reference excerpt below once, without taking notes.
  2. Close the page and write down what Df (Unix) means in your own words.
  3. Compare your version with the excerpt and mark what you missed.
  4. Work through the three examples above with pen and paper.
  5. Explain Df (Unix) out loud to somebody else — or to Teacher Smith in the lgStudy chat.

Frequently asked questions

What is Df (Unix) in simple terms?

df is a shell command for reporting the amount of available and consumed storage space on a file system. Although df is short for disk free, the command is not limited to disk storage.

Why does Df (Unix) matter?

Because it connects several science ideas at once: it gives you a definition you can apply, a quantity you can calculate, and a way to check whether a result is plausible.

How should I study Df (Unix)?

Read the excerpt, restate it from memory, then work through the examples and applications listed on this page. The five-step study plan above takes about twenty minutes.

What does this page cover?

It gives you a compact reference excerpt plus original lgStudy explanations, examples, applications and study material on Df (Unix).

Tags

  • Standard Unix programs
  • Unix SUS2008 utilities

Keep exploring