Linux and Command-Line Basics
A Linux server warns that disk space is running low. Which of the following is the correct pair of a command to check usage and free space for each file system and a command to total the space used by the files in a directory?
- Adf and du
- Bdu and df
- Cfree and du
Show answer and explanation
Answer: A. df and du
df (disk free) shows, for each mounted file system, its total size, used space and free space, and with -h it shows them readably in units such as G and M. du (disk usage) totals the space used by the files under a given directory, and used as in du -sh * it finds which directories are large. A standard procedure is to first find the full file system with df and then narrow down the large directories inside it with du. A file that has been deleted but is still held open by a process is counted as used by df but not by du, so the two values may not match.
- A. Correct. Free space per file system is checked with df, and the total used under a directory with du.
- B. The roles of df and du are reversed.
- C. free shows usage of memory (main memory and swap), not disk.