Which command in Linux is used to estimate and display the disk space usage of…
2023
Which command in Linux is used to estimate and display the disk space usage of files and directories?
- A.
ls
- B.
df
- C.
du
- D.
top
- E.
mkdir
Attempted by 3 students.
Show answer & explanation
Correct answer: C
Concept
Linux disk-related commands split into two distinct jobs. One job reports usage at the level of individual files and directory trees (how much space a given set of files occupies). The other job reports usage at the level of whole mounted filesystems (how much total space and free space a partition has). The first is what “estimate and display the disk space usage of files and directories” asks for.
Application
The du command (short for “disk usage”) walks a file or directory tree and reports the space occupied by each item, summarising recursively. Running du -sh /path prints a single human-readable total for that path, which is exactly the per-file/per-directory estimate the question describes.
Contrast
dfreports free and used space for whole mounted filesystems, not for individual files or directories.lslists directory contents (names, permissions, sizes of entries) but does not total or estimate tree usage.topis a live process/CPU/memory monitor and reports nothing about disk space.mkdircreates a new directory and performs no measurement at all.
So the command that estimates and displays disk-space usage of files and directories is du.