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?

  1. Adf and du
  2. Bdu and df
  3. 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.
Practice this topic Back to topic

Books on Linux and Command-Line Basics Ad

As an Amazon Associate I earn from qualifying purchases.

More Linux and Command-Line Basics questions

  1. You created a public-key authentication key pair with ssh-keygen on your own PC and want to connect to the server server1 with ssh without a password. Which of the following is the correct way to place the keys?
  2. Which of the following is what happens when "tar -czf proj.tar.gz proj/" is run?
  3. After editing main.c, a file managed with Git, only git commit -m "fix" was run, and "no changes added to commit" was shown and nothing was committed. Which of the following is the reason?
  4. You ran git commit in Git, but the commit does not yet appear in the GitHub repository shared by the team. Which of the following is the reason?
  5. "build/" was written in the .gitignore of a project managed with Git, but changes to build/out.log, which was committed earlier, keep appearing in git status. Which of the following is the reason?